Module: Mongoid::Extensions::Array::ClassMethods
- Defined in:
- lib/mongoid/extensions/array.rb
Instance Method Summary collapse
-
#__mongoize_fk__(association, object) ⇒ Array
Convert the provided object to a proper 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__(association, object) ⇒ Array
Convert the provided object to a proper array of foreign keys.
153 154 155 156 157 158 159 |
# File 'lib/mongoid/extensions/array.rb', line 153 def __mongoize_fk__(association, object) if object.resizable? object.blank? ? object : association.convert_to_foreign_key(object) else object.blank? ? [] : association.convert_to_foreign_key(Array(object)) end end |
#mongoize(object) ⇒ Array
Turn the object from the ruby type we deal with to a Mongo friendly type.
172 173 174 175 176 177 178 |
# File 'lib/mongoid/extensions/array.rb', line 172 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?
188 189 190 |
# File 'lib/mongoid/extensions/array.rb', line 188 def resizable? true end |