Module: RUUID::Mongoid::Extensions::UUID::ClassMethods
- Defined in:
- lib/ruuid/mongoid/extensions/uuid.rb
Instance Method Summary collapse
-
#demongoize(object) ⇒ RUUID::UUID
Convert the object from its Mongo-friendly Ruby type to this type.
-
#mongoize(object) ⇒ BSON::Binary
(also: #evolve)
Turn the object from the Ruby type we deal with to a Mongo-friendly type.
Instance Method Details
#demongoize(object) ⇒ RUUID::UUID
Convert the object from its Mongo-friendly Ruby type to this type.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruuid/mongoid/extensions/uuid.rb', line 24 def demongoize(object) case object when BSON::Binary new(object.data) when ::String parse(object) else object end end |
#mongoize(object) ⇒ BSON::Binary Also known as: evolve
Turn the object from the Ruby type we deal with to a Mongo-friendly type.
43 44 45 46 |
# File 'lib/ruuid/mongoid/extensions/uuid.rb', line 43 def mongoize(object) return object if object.nil? parse(object).mongoize rescue object.mongoize end |