Created
March 14, 2011 21:36
-
-
Save astevens/869935 to your computer and use it in GitHub Desktop.
Merb/Mongoid fix for ParseTree gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Mongoid | |
module Extensions | |
module Object | |
module Reflections | |
extend ActiveSupport::Concern | |
alias :invar :ivar | |
undef :ivar | |
def invar(name) | |
if instance_variable_defined?("@#{name}") | |
return instance_variable_get("@#{name}") | |
end | |
nil | |
end | |
end | |
end | |
end | |
end | |
module Mongoid | |
module Relations | |
module Accessors | |
def relation_exists?(name) | |
invar(name) | |
end | |
def substitute(name, object, options) | |
set(name, invar(name).substitute(object, options)) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment