Module: Mongoid::Extensions::Object::Reflections
- Extended by:
- ActiveSupport::Concern
- Included in:
- Object
- Defined in:
- lib/mongoid/extensions/object/reflections.rb
Overview
This module contains reflection convenience methods.
Instance Method Summary collapse
-
#ivar(name) ⇒ Object?
Get the value for an instance variable or nil if it doesn’t exist.
-
#remove_ivar(name) ⇒ true, false
Remove the instance variable for the provided name.
Instance Method Details
#ivar(name) ⇒ Object?
Get the value for an instance variable or nil if it doesn’t exist.
20 21 22 23 24 25 26 |
# File 'lib/mongoid/extensions/object/reflections.rb', line 20 def ivar(name) if instance_variable_defined?("@#{name}") return instance_variable_get("@#{name}") else false end end |
#remove_ivar(name) ⇒ true, false
Remove the instance variable for the provided name.
38 39 40 41 42 43 44 |
# File 'lib/mongoid/extensions/object/reflections.rb', line 38 def remove_ivar(name) if instance_variable_defined?("@#{name}") return remove_instance_variable("@#{name}") else false end end |