Module: CouchPotato::Persistence::Json::ClassMethods

Defined in:
lib/couch_potato/persistence/json.rb

Instance Method Summary collapse

Instance Method Details

#json_create(json) ⇒ Object

creates a model instance from JSON



42
43
44
45
46
47
48
# File 'lib/couch_potato/persistence/json.rb', line 42

def json_create(json)
  return if json.nil?
  instance = self.new :_document => HashWithIndifferentAccess.new(json)
  instance._id = json[:_id] || json['_id']
  instance._rev = json[:_rev] || json['_rev']
  instance
end