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, association) ⇒ InvalidInclude

Returns a new instance of InvalidInclude.



163
164
165
166
# File 'lib/jsonapi/exceptions.rb', line 163

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

Instance Attribute Details

#associationObject

Returns the value of attribute association.



162
163
164
# File 'lib/jsonapi/exceptions.rb', line 162

def association
  @association
end

#resourceObject

Returns the value of attribute resource.



162
163
164
# File 'lib/jsonapi/exceptions.rb', line 162

def resource
  @resource
end

Instance Method Details

#errorsObject



168
169
170
171
172
173
# File 'lib/jsonapi/exceptions.rb', line 168

def errors
  [JSONAPI::Error.new(code: JSONAPI::INVALID_INCLUDE,
                      status: :bad_request,
                      title: 'Invalid field',
                      detail: "#{association} is not a valid association of #{resource}")]
end