Module: MongoMapper::Extensions::Binary

Included in:
Binary
Defined in:
lib/mongo_mapper/extensions/binary.rb

Instance Method Summary collapse

Instance Method Details

#from_mongo(value) ⇒ Object



13
14
15
# File 'lib/mongo_mapper/extensions/binary.rb', line 13

def from_mongo(value)
  value
end

#to_mongo(value) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/mongo_mapper/extensions/binary.rb', line 5

def to_mongo(value)
  if value.is_a?(::BSON::Binary)
    value
  else
    value.nil? ? nil : ::BSON::Binary.new(value)
  end
end