Class: ActionPolicy::Policy::ExecutionResult
- Inherits:
-
Object
- Object
- ActionPolicy::Policy::ExecutionResult
- Defined in:
- lib/action_policy/policy/execution_result.rb
Overview
Result of applying a policy rule
This class could be extended by some modules to provide additional functionality
Instance Attribute Summary collapse
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #cached! ⇒ Object
- #cached? ⇒ Boolean
- #fail? ⇒ Boolean
-
#initialize(policy, rule) ⇒ ExecutionResult
constructor
A new instance of ExecutionResult.
- #inspect ⇒ Object
-
#load(value) ⇒ Object
Populate the final value.
- #success? ⇒ Boolean
Constructor Details
#initialize(policy, rule) ⇒ ExecutionResult
Returns a new instance of ExecutionResult.
12 13 14 15 |
# File 'lib/action_policy/policy/execution_result.rb', line 12 def initialize(policy, rule) @policy = policy @rule = rule end |
Instance Attribute Details
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
10 11 12 |
# File 'lib/action_policy/policy/execution_result.rb', line 10 def policy @policy end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
10 11 12 |
# File 'lib/action_policy/policy/execution_result.rb', line 10 def rule @rule end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/action_policy/policy/execution_result.rb', line 10 def value @value end |
Instance Method Details
#cached! ⇒ Object
26 27 28 |
# File 'lib/action_policy/policy/execution_result.rb', line 26 def cached! @cached = true end |
#cached? ⇒ Boolean
30 |
# File 'lib/action_policy/policy/execution_result.rb', line 30 def cached?() = @cached == true |
#fail? ⇒ Boolean
24 |
# File 'lib/action_policy/policy/execution_result.rb', line 24 def fail?() = @value == false |
#inspect ⇒ Object
32 33 34 |
# File 'lib/action_policy/policy/execution_result.rb', line 32 def inspect "<#{policy}##{rule}: #{@value}>" end |
#load(value) ⇒ Object
Populate the final value
18 19 20 |
# File 'lib/action_policy/policy/execution_result.rb', line 18 def load(value) @value = value end |
#success? ⇒ Boolean
22 |
# File 'lib/action_policy/policy/execution_result.rb', line 22 def success?() = @value == true |