Class: Parametric::NullablePolicy::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/parametric/nullable_policy.rb

Instance Method Summary collapse

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.

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


34
35
36
# File 'lib/parametric/nullable_policy.rb', line 34

def include_non_eligible_in_ouput?
  true
end

#messageString

Error message for this policy

Returns:

  • (String)


52
53
54
# File 'lib/parametric/nullable_policy.rb', line 52

def message
  ''
end

#valid?Boolean

If [false], add [#message] to result errors and halt processing field.

Returns:

  • (Boolean)


40
41
42
# File 'lib/parametric/nullable_policy.rb', line 40

def valid?
  true
end

#valueAny

Coerce the value, or return as-is.

Returns:

  • (Any)


46
47
48
# File 'lib/parametric/nullable_policy.rb', line 46

def value
  @value
end