Class: MongoModel::Types::Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomodel/support/types/hash.rb

Instance Method Summary collapse

Methods inherited from Object

#boolean, #cast, #to_query

Instance Method Details

#from_mongo(hash) ⇒ Object



13
14
15
# File 'lib/mongomodel/support/types/hash.rb', line 13

def from_mongo(hash)
  hash.with_indifferent_access if hash
end

#to_mongo(hash) ⇒ Object



6
7
8
9
10
11
# File 'lib/mongomodel/support/types/hash.rb', line 6

def to_mongo(hash)
  hash.inject({}) { |result, (k, v)|
    result[convert(k)] = convert(v)
    result
  } if hash
end