module MongoMapper::Extensions::Hash::ClassMethods
Public Instance Methods
from_mongo(value)
click to toggle source
# File lib/mongo_mapper/extensions/hash.rb, line 31 def from_mongo(value) HashWithIndifferentAccess.new(value || {}) end
to_mongo(value, options = {})
click to toggle source
# File lib/mongo_mapper/extensions/hash.rb, line 10 def to_mongo(value, options = {}) stringify_bson = options[:stringify_bson] recursive = options[:recursive] value = value.clone if recursive hash = value.to_hash hash.each do |k,v| case v when Document, EmbeddedDocument, Hash, Array, Set v = v.to_mongo(options) if v and recursive when BSON::ObjectId, BSON::Binary v = v.to_s if stringify_bson end hash[k] = v end hash end