Class: Hash
Instance Method Summary collapse
-
#symbolize_keys ⇒ Object
Same symbolize_keys method used in Rails.
- #symbolize_keys! ⇒ Object
-
#to_mongo_value ⇒ Object
Convert an Hash to a Mongo value.
Instance Method Details
#symbolize_keys ⇒ Object
Same symbolize_keys method used in Rails
54 55 56 57 58 59 |
# File 'lib/mongo_record/core_ext.rb', line 54 def symbolize_keys inject({}) do |, (key, value)| [(key.to_sym rescue key) || key] = value end end |
#symbolize_keys! ⇒ Object
61 62 63 |
# File 'lib/mongo_record/core_ext.rb', line 61 def symbolize_keys! self.replace(self.symbolize_keys) end |
#to_mongo_value ⇒ Object
Convert an Hash to a Mongo value. Used by MongoRecord::Base when saving data to Mongo.
47 48 49 50 51 |
# File 'lib/mongo_record/core_ext.rb', line 47 def to_mongo_value h = {} self.each {|k,v| h[k] = v.to_mongo_value} h end |