Module: CouchTomato::Persistence::Json::ClassMethods
- Defined in:
- lib/couch_tomato/persistence/json.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
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/couch_tomato/persistence/json.rb', line 34 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. = instance end |