Exception: JSONAPI::Exceptions::InvalidResource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ InvalidResource


31
32
33
# File 'lib/jsonapi/exceptions.rb', line 31

def initialize(resource)
  @resource = resource
end

Instance Attribute Details

#resourceObject

Returns the value of attribute resource


30
31
32
# File 'lib/jsonapi/exceptions.rb', line 30

def resource
  @resource
end

Instance Method Details

#errorsObject


35
36
37
38
39
40
41
42
# File 'lib/jsonapi/exceptions.rb', line 35

def errors
  [JSONAPI::Error.new(code: JSONAPI::INVALID_RESOURCE,
                      status: :bad_request,
                      title: I18n.t('jsonapi-resources.exceptions.invalid_resource.title',
                                    default: 'Invalid resource'),
                      detail: I18n.t('jsonapi-resources.exceptions.invalid_resource.detail',
                                     default: "#{resource} is not a valid resource.", resource: resource))]
end