Module: Mongoid::Extensions::Array::ClassMethods
- Defined in:
- lib/mongoid/extensions/array.rb
Instance Method Summary collapse
-
#__mongoize_fk__(constraint, object) ⇒ Array
Convert the provided object to a propery array of foreign keys.
-
#mongoize(object) ⇒ Array
Turn the object from the ruby type we deal with to a Mongo friendly type.
-
#resizable? ⇒ true
Is the object’s size changable?.
Instance Method Details
#__mongoize_fk__(constraint, object) ⇒ Array
Convert the provided object to a propery array of foreign keys.
136 137 138 139 140 141 142 |
# File 'lib/mongoid/extensions/array.rb', line 136 def __mongoize_fk__(constraint, object) if object.resizable? object.blank? ? object : constraint.convert(object) else object.blank? ? [] : constraint.convert(Array(object)) end end |
#mongoize(object) ⇒ Array
Turn the object from the ruby type we deal with to a Mongo friendly type.
155 156 157 158 159 160 161 |
# File 'lib/mongoid/extensions/array.rb', line 155 def mongoize(object) if object.is_a?(::Array) evolve(object).collect{ |obj| obj.class.mongoize(obj) } else evolve(object) end end |
#resizable? ⇒ true
Is the object’s size changable?
171 172 173 |
# File 'lib/mongoid/extensions/array.rb', line 171 def resizable? true end |