Class: Parametric::NullablePolicy::Runner
- Inherits:
-
Object
- Object
- Parametric::NullablePolicy::Runner
- Defined in:
- lib/parametric/nullable_policy.rb
Instance Method Summary collapse
-
#eligible? ⇒ Boolean
Should this policy run at all? returning [false] halts the field policy chain.
-
#include_non_eligible_in_ouput? ⇒ Boolean
If this policy is not eligible, should the key and value be included in the output?.
-
#initialize(key, value, payload, context) ⇒ Runner
constructor
A new instance of Runner.
-
#message ⇒ String
Error message for this policy.
-
#valid? ⇒ Boolean
If [false], add [#message] to result errors and halt processing field.
-
#value ⇒ Any
Coerce the value, or return as-is.
Constructor Details
#initialize(key, value, payload, context) ⇒ Runner
Returns a new instance of Runner.
18 19 20 21 22 23 |
# File 'lib/parametric/nullable_policy.rb', line 18 def initialize(key, value, payload, context) @key = key @value = value @payload = payload @context = context end |
Instance Method Details
#eligible? ⇒ Boolean
Should this policy run at all? returning [false] halts the field policy chain.
28 29 30 |
# File 'lib/parametric/nullable_policy.rb', line 28 def eligible? @payload.key?(@key) && !@value.nil? end |
#include_non_eligible_in_ouput? ⇒ Boolean
If this policy is not eligible, should the key and value be included in the output?
34 35 36 |
# File 'lib/parametric/nullable_policy.rb', line 34 def include_non_eligible_in_ouput? true end |
#message ⇒ String
Error message for this policy
52 53 54 |
# File 'lib/parametric/nullable_policy.rb', line 52 def '' end |
#valid? ⇒ Boolean
If [false], add [#message] to result errors and halt processing field.
40 41 42 |
# File 'lib/parametric/nullable_policy.rb', line 40 def valid? true end |
#value ⇒ Any
Coerce the value, or return as-is.
46 47 48 |
# File 'lib/parametric/nullable_policy.rb', line 46 def value @value end |