Skip to content

Instantly share code, notes, and snippets.

@astevens
Created March 14, 2011 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astevens/869935 to your computer and use it in GitHub Desktop.
Save astevens/869935 to your computer and use it in GitHub Desktop.
Merb/Mongoid fix for ParseTree gem
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