Class: Parametric::PolicyAdapter::PolicyRunner
- Inherits:
-
Object
- Object
- Parametric::PolicyAdapter::PolicyRunner
- Defined in:
- lib/parametric/policy_adapter.rb
Instance Method Summary collapse
-
#eligible? ⇒ Boolean
The PolicyRunner interface.
-
#include_non_eligible_in_ouput? ⇒ Boolean
If a policy is not #eligible?, use this to decide if its key should still be included in output hash.
-
#initialize(policy, key, value, payload, context) ⇒ PolicyRunner
constructor
A new instance of PolicyRunner.
- #message ⇒ String
- #valid? ⇒ Boolean
- #value ⇒ Any
Constructor Details
#initialize(policy, key, value, payload, context) ⇒ PolicyRunner
Returns a new instance of PolicyRunner.
7 8 9 |
# File 'lib/parametric/policy_adapter.rb', line 7 def initialize(policy, key, value, payload, context) @policy, @key, @raw_value, @payload, @context = policy, key, value, payload, context end |
Instance Method Details
#eligible? ⇒ Boolean
The PolicyRunner interface
13 14 15 |
# File 'lib/parametric/policy_adapter.rb', line 13 def eligible? @policy.eligible?(@raw_value, @key, @payload) end |
#include_non_eligible_in_ouput? ⇒ Boolean
If a policy is not #eligible?, use this to decide if its key should still be included in output hash.
21 22 23 |
# File 'lib/parametric/policy_adapter.rb', line 21 def include_non_eligible_in_ouput? false end |
#message ⇒ String
36 37 38 |
# File 'lib/parametric/policy_adapter.rb', line 36 def @policy. end |
#valid? ⇒ Boolean
26 27 28 |
# File 'lib/parametric/policy_adapter.rb', line 26 def valid? @policy.valid?(value, @key, @payload) end |
#value ⇒ Any
31 32 33 |
# File 'lib/parametric/policy_adapter.rb', line 31 def value @value ||= @policy.coerce(@raw_value, @key, @context) end |