Exception: ViewModel::DeserializationError::InvalidAttributeType

Inherits:
InvalidRequest show all
Defined in:
lib/view_model/deserialization_error.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractErrorWithBlame

#nodes

Instance Method Summary collapse

Methods inherited from ViewModel::DeserializationError

#code

Methods inherited from AbstractError

#aggregation?, #causes, #code, #exception, #status, #title, #to_s, #view

Constructor Details

#initialize(attribute, expected_type, provided_type, node) ⇒ InvalidAttributeType

Returns a new instance of InvalidAttributeType.



295
296
297
298
299
300
# File 'lib/view_model/deserialization_error.rb', line 295

def initialize(attribute, expected_type, provided_type, node)
  @attribute     = attribute
  @expected_type = expected_type
  @provided_type = provided_type
  super([node])
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



293
294
295
# File 'lib/view_model/deserialization_error.rb', line 293

def attribute
  @attribute
end

#expected_typeObject (readonly)

Returns the value of attribute expected_type.



293
294
295
# File 'lib/view_model/deserialization_error.rb', line 293

def expected_type
  @expected_type
end

#provided_typeObject (readonly)

Returns the value of attribute provided_type.



293
294
295
# File 'lib/view_model/deserialization_error.rb', line 293

def provided_type
  @provided_type
end

Instance Method Details

#detailObject



302
303
304
# File 'lib/view_model/deserialization_error.rb', line 302

def detail
  "Expected '#{attribute}' to be of type '#{expected_type}', was '#{provided_type}'"
end

#metaObject



306
307
308
309
310
# File 'lib/view_model/deserialization_error.rb', line 306

def meta
  super.merge(attribute:     attribute,
              expected_type: expected_type,
              provided_type: provided_type)
end