Method: Gecko::Record::BaseAdapter#fetch

Defined in:
lib/gecko/record/base_adapter.rb

#fetch(id) ⇒ Gecko::Record::Base?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Fetch a record via API, regardless of whether it is already in identity map.

Examples:

client.Product.fetch(12)

Parameters:

  • id (Integer)

    ID of record

Returns:



204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/gecko/record/base_adapter.rb', line 204

def fetch(id) # rubocop:disable Metrics/MethodLength
  verify_id_presence!(id)
  response = request(:get, plural_path + '/' + id.to_s)
  record_json = extract_record(response.parsed)
  instantiate_and_register_record(record_json)
rescue OAuth2::Error => e
  case e.response.status
  when 404
    record_not_found!(id)
  else
    raise
  end
end