Exception: ViewModel::DeserializationError::AssociatedNotFound

Inherits:
NotFound 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(association, missing_nodes, blame_nodes) ⇒ AssociatedNotFound

Returns a new instance of AssociatedNotFound.



196
197
198
199
200
# File 'lib/view_model/deserialization_error.rb', line 196

def initialize(association, missing_nodes, blame_nodes)
  @association   = association
  @missing_nodes = Array.wrap(missing_nodes)
  super(blame_nodes)
end

Instance Attribute Details

#associationObject (readonly)

Returns the value of attribute association.



194
195
196
# File 'lib/view_model/deserialization_error.rb', line 194

def association
  @association
end

#missing_nodesObject (readonly)

Returns the value of attribute missing_nodes.



194
195
196
# File 'lib/view_model/deserialization_error.rb', line 194

def missing_nodes
  @missing_nodes
end

Instance Method Details

#detailObject



202
203
204
205
206
# File 'lib/view_model/deserialization_error.rb', line 202

def detail
  errors = missing_nodes.map(&:to_s).join(', ')
  "Couldn't find requested member node(s) in association '#{association}': "\
  "#{errors}"
end

#metaObject



208
209
210
211
# File 'lib/view_model/deserialization_error.rb', line 208

def meta
  super.merge(association: association,
              missing_nodes: format_references(missing_nodes))
end