Exception: JSONAPI::Exceptions::InvalidInclude

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, relationship) ⇒ InvalidInclude


254
255
256
257
# File 'lib/jsonapi/exceptions.rb', line 254

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

Instance Attribute Details

#relationshipObject

Returns the value of attribute relationship


253
254
255
# File 'lib/jsonapi/exceptions.rb', line 253

def relationship
  @relationship
end

#resourceObject

Returns the value of attribute resource


253
254
255
# File 'lib/jsonapi/exceptions.rb', line 253

def resource
  @resource
end

Instance Method Details

#errorsObject


259
260
261
262
263
264
265
266
267
# File 'lib/jsonapi/exceptions.rb', line 259

def errors
  [JSONAPI::Error.new(code: JSONAPI::INVALID_INCLUDE,
                      status: :bad_request,
                      title: I18n.translate('jsonapi-resources.exceptions.invalid_include.title',
                                            default: 'Invalid field'),
                      detail: I18n.translate('jsonapi-resources.exceptions.invalid_include.detail',
                                             default: "#{relationship} is not a valid relationship of #{resource}",
                                             relationship: relationship, resource: resource))]
end