Exception: JSONAPI::Exceptions::InvalidField

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, field) ⇒ InvalidField

Returns a new instance of InvalidField.



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

def initialize(type, field)
  @field = field
  @type = type
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



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

def field
  @field
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#errorsObject



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

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