Method: ObjectJSONMapper::Base.find

Defined in:
lib/object_json_mapper/base.rb

.find(id) ⇒ ObjectJSONMapper::Base

Returns current model instance.

Parameters:

  • id (Integer)

Returns:



143
144
145
146
147
148
149
150
151
# File 'lib/object_json_mapper/base.rb', line 143

def find(id)
  raise ActiveRecord::RecordNotFound if id.nil?

  result = HTTP.parse_json(client[id].get.body)

  persist(result)
rescue RestClient::ExceptionWithResponse
  raise ActiveRecord::RecordNotFound
end