Module: CouchTomato::Persistence::Nested::ClassMethods
- Defined in:
- lib/couch_tomato/persistence.rb
Instance Method Summary collapse
-
#json_create(json, meta = {}) ⇒ Object
creates a model instance from JSON.
Instance Method Details
#json_create(json, meta = {}) ⇒ Object
creates a model instance from JSON
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/couch_tomato/persistence.rb', line 43 def json_create(json, ={}) return if json.nil? instance = self.new # instance._id = json[:_id] || json['_id'] # instance._rev = json[:_rev] || json['_rev'] properties.each do |property| property.build(instance, json) end instance end |