Module: Mongoid::Extensions::Object
- Defined in:
- lib/mongoid/extensions/object.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary (collapse)
-
- (Object) __evolve_object_id__
Evolve a plain object into an object id.
-
- (Object) __mongoize_time__
Mongoize a plain object into a time.
-
- (Object?) do_or_do_not(name, *args)
Do or do not, there is no try.
-
- (Object?) ivar(name)
Get the value for an instance variable or nil if it doesn't exist.
-
- (Object) mongoize
Turn the object from the ruby type we deal with to a Mongo friendly type.
-
- (true, false) remove_ivar(name)
Remove the instance variable for the provided name.
-
- (false) resizable?
Is the object's size changable? Only returns true for arrays and hashes currently.
-
- (Object) substitutable
Get the substitutable version of an object.
-
- (Object?) you_must(name, *args)
You must unlearn what you have learned.
Instance Method Details
- (Object) __evolve_object_id__
Evolve a plain object into an object id.
14 15 16 |
# File 'lib/mongoid/extensions/object.rb', line 14 def __evolve_object_id__ self end |
- (Object) __mongoize_time__
Mongoize a plain object into a time.
26 27 28 |
# File 'lib/mongoid/extensions/object.rb', line 26 def __mongoize_time__ self end |
- (Object?) do_or_do_not(name, *args)
Do or do not, there is no try. -- Yoda.
42 43 44 |
# File 'lib/mongoid/extensions/object.rb', line 42 def do_or_do_not(name, *args) send(name, *args) if name && respond_to?(name) end |
- (Object?) ivar(name)
Get the value for an instance variable or nil if it doesn't exist.
56 57 58 59 60 61 62 |
# File 'lib/mongoid/extensions/object.rb', line 56 def ivar(name) if instance_variable_defined?("@#{name}") return instance_variable_get("@#{name}") else false end end |
- (Object) mongoize
Turn the object from the ruby type we deal with to a Mongo friendly type.
73 74 75 |
# File 'lib/mongoid/extensions/object.rb', line 73 def mongoize self end |
- (true, false) remove_ivar(name)
Remove the instance variable for the provided name.
87 88 89 90 91 92 93 |
# File 'lib/mongoid/extensions/object.rb', line 87 def remove_ivar(name) if instance_variable_defined?("@#{name}") return remove_instance_variable("@#{name}") else false end end |
- (false) resizable?
Is the object's size changable? Only returns true for arrays and hashes currently.
104 105 106 |
# File 'lib/mongoid/extensions/object.rb', line 104 def resizable? false end |
- (Object) substitutable
Get the substitutable version of an object.
116 117 118 |
# File 'lib/mongoid/extensions/object.rb', line 116 def substitutable self end |
- (Object?) you_must(name, *args)
You must unlearn what you have learned. -- Yoda
132 133 134 |
# File 'lib/mongoid/extensions/object.rb', line 132 def you_must(name, *args) frozen? ? nil : do_or_do_not(name, *args) end |