Exception: JSONAPI::Exceptions::InvalidSortCriteria

Inherits:
Error
  • Object
show all
Defined in:
lib/jsonapi/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, sort_criteria) ⇒ InvalidSortCriteria


272
273
274
275
# File 'lib/jsonapi/exceptions.rb', line 272

def initialize(resource, sort_criteria)
  @resource = resource
  @sort_criteria = sort_criteria
end

Instance Attribute Details

#resourceObject

Returns the value of attribute resource


271
272
273
# File 'lib/jsonapi/exceptions.rb', line 271

def resource
  @resource
end

#sort_criteriaObject

Returns the value of attribute sort_criteria


271
272
273
# File 'lib/jsonapi/exceptions.rb', line 271

def sort_criteria
  @sort_criteria
end

Instance Method Details

#errorsObject


277
278
279
280
281
282
283
284
285
# File 'lib/jsonapi/exceptions.rb', line 277

def errors
  [JSONAPI::Error.new(code: JSONAPI::INVALID_SORT_CRITERIA,
                      status: :bad_request,
                      title: I18n.translate('jsonapi-resources.exceptions.invalid_sort_criteria.title',
                                            default: 'Invalid sort criteria'),
                      detail: I18n.translate('jsonapi-resources.exceptions.invalid_sort_criteria.detail',
                                             default: "#{sort_criteria} is not a valid sort criteria for #{resource}",
                                             sort_criteria: sort_criteria, resource: resource))]
end