Class: ViewModel::AccessControl::Result
- Inherits:
-
Struct
- Object
- Struct
- ViewModel::AccessControl::Result
- Defined in:
- lib/view_model/access_control.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#permit ⇒ Object
(also: #permit?)
Returns the value of attribute permit.
Instance Method Summary collapse
-
#initialize(permit, error: nil) ⇒ Result
constructor
A new instance of Result.
-
#merge(&_block) ⇒ Object
Merge this result with another access control result.
Constructor Details
#initialize(permit, error: nil) ⇒ Result
Returns a new instance of Result.
15 16 17 18 19 |
# File 'lib/view_model/access_control.rb', line 15 def initialize(permit, error: nil) raise ArgumentError.new('Successful AccessControl::Result may not have an error') if permit && error super(permit, error) end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error
14 15 16 |
# File 'lib/view_model/access_control.rb', line 14 def error @error end |
#permit ⇒ Object Also known as: permit?
Returns the value of attribute permit
14 15 16 |
# File 'lib/view_model/access_control.rb', line 14 def permit @permit end |
Instance Method Details
#merge(&_block) ⇒ Object
Merge this result with another access control result. Takes a block returning a result, and returns a combined result for both tests. Access is permitted if both results permit. Otherwise, access is denied with the error value of the first denying Result.
27 28 29 30 31 32 33 |
# File 'lib/view_model/access_control.rb', line 27 def merge(&_block) if permit? yield else self end end |