Exception: ViewModel::DeserializationError::SchemaVersionMismatch

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

Overview

A view included an unexpected schema version for the corresponding viewmodel.

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(viewmodel_class, schema_version, nodes) ⇒ SchemaVersionMismatch

Returns a new instance of SchemaVersionMismatch.



128
129
130
131
132
# File 'lib/view_model/deserialization_error.rb', line 128

def initialize(viewmodel_class, schema_version, nodes)
  @viewmodel_class = viewmodel_class
  @schema_version  = schema_version
  super(nodes)
end

Instance Attribute Details

#schema_versionObject (readonly)

Returns the value of attribute schema_version.



126
127
128
# File 'lib/view_model/deserialization_error.rb', line 126

def schema_version
  @schema_version
end

#viewmodel_classObject (readonly)

Returns the value of attribute viewmodel_class.



126
127
128
# File 'lib/view_model/deserialization_error.rb', line 126

def viewmodel_class
  @viewmodel_class
end

Instance Method Details

#detailObject



134
135
136
137
# File 'lib/view_model/deserialization_error.rb', line 134

def detail
  "Mismatched schema version for type #{viewmodel_class.view_name}, "\
  "expected #{viewmodel_class.schema_version}, received #{schema_version}."
end

#metaObject



139
140
141
142
# File 'lib/view_model/deserialization_error.rb', line 139

def meta
  super.merge(expected: viewmodel_class.schema_version,
              received: schema_version)
end