Exception: ViewModel::AccessControl::Composed::NoRequiredConditionsError

Inherits:
ViewModel::AccessControlError show all
Defined in:
lib/view_model/access_control/composed.rb

Overview

Error type when no ‘if` conditions succeed.

Instance Attribute Summary collapse

Attributes inherited from ViewModel::AccessControlError

#detail

Attributes inherited from ViewModel::AbstractErrorWithBlame

#nodes

Instance Method Summary collapse

Methods inherited from ViewModel::AbstractError

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

Constructor Details

#initialize(nodes, reasons) ⇒ NoRequiredConditionsError

Returns a new instance of NoRequiredConditionsError.



83
84
85
86
# File 'lib/view_model/access_control/composed.rb', line 83

def initialize(nodes, reasons)
  super('Action not permitted because none of the possible conditions were met.', nodes)
  @reasons = reasons
end

Instance Attribute Details

#reasonsObject (readonly)

Returns the value of attribute reasons.



81
82
83
# File 'lib/view_model/access_control/composed.rb', line 81

def reasons
  @reasons
end

Instance Method Details

#merge(other) ⇒ Object



92
93
94
95
# File 'lib/view_model/access_control/composed.rb', line 92

def merge(other)
  NoRequiredConditionsError.new(nodes | other.nodes,
                                Lazily.concat(reasons, other.reasons).uniq)
end

#metaObject



88
89
90
# File 'lib/view_model/access_control/composed.rb', line 88

def meta
  super.merge(conditions: @reasons.to_a)
end