Method: JsonApiModel::Scope#first

Defined in:
lib/json_api_model/scope.rb

#firstObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/json_api_model/scope.rb', line 23

def first
  JsonApiModel.instrumenter.instrument 'first.json_api_model', url: url do
    # if the non-first query has already been executed, there's no need to make the call again
    if cached?
      cache.first
    else
      cache_or_find :first do
        @model_class.new_from_client @client_scope.first
      end
    end
  end
end