Module: Mongoid::Extensions::Vector::ClassMethods
- Defined in:
- lib/mongoid/extensions/vector.rb
Instance Method Summary collapse
-
#demongoize(object) ⇒ BSON::Vector | nil
Convert the object from its mongo friendly ruby type back to a BSON::Vector.
-
#mongoize(object) ⇒ BSON::Binary | nil
Mongoize an object of any type to how it's stored in the db.
Instance Method Details
#demongoize(object) ⇒ BSON::Vector | nil
Convert the object from its mongo friendly ruby type back to a BSON::Vector.
50 51 52 53 54 55 |
# File 'lib/mongoid/extensions/vector.rb', line 50 def demongoize(object) case object when BSON::Binary then (object.type == :vector) ? object.as_vector : nil when BSON::Vector then object end end |
#mongoize(object) ⇒ BSON::Binary | nil
Mongoize an object of any type to how it's stored in the db.
34 35 36 37 38 39 |
# File 'lib/mongoid/extensions/vector.rb', line 34 def mongoize(object) case object when BSON::Vector then BSON::Binary.from_vector(object) when BSON::Binary then object end end |