class JsonApiResource::Connections::ServerConnection

Public Instance Methods

report_error( e ) click to toggle source
# File lib/json_api_resource/connections/server_connection.rb, line 6
def report_error( e )
  error_notifier.notify( self, e ) if error_notifier.present?
end
request( action, *args ) click to toggle source
# File lib/json_api_resource/connections/server_connection.rb, line 10
def request( action, *args )

  client_args = args.deep_dup
  result = self.client.send action, *client_args

  if result.is_a? JsonApiClient::Scope
    result = result.all
  end

  result

rescue JsonApiClient::Errors::NotFound => e

  result = JsonApiClient::ResultSet.new

  result.meta = {status: 404}

  result.errors = ActiveModel::Errors.new(result)
  result.errors.add("RecordNotFound", e.message)

  result

end