Module: Mongoid::Extensions::Set::ClassMethods
- Defined in:
- lib/mongoid/extensions/set.rb
Instance Method Summary collapse
-
#demongoize(object) ⇒ Set
Convert the object from its mongo friendly ruby type to this type.
-
#mongoize(object) ⇒ Array | nil
Turn the object from the ruby type we deal with to a Mongo friendly type.
Instance Method Details
#demongoize(object) ⇒ Set
Convert the object from its mongo friendly ruby type to this type.
37 38 39 40 41 42 |
# File 'lib/mongoid/extensions/set.rb', line 37 def demongoize(object) case object when ::Set then object when ::Array then ::Set.new(object) end end |
#mongoize(object) ⇒ Array | nil
Turn the object from the ruby type we deal with to a Mongo friendly type.
53 54 55 56 57 58 59 60 |
# File 'lib/mongoid/extensions/set.rb', line 53 def mongoize(object) return if object.nil? case object when ::Set then ::Array.mongoize(object.to_a).uniq when ::Array then ::Array.mongoize(object).uniq end end |