Class: Parametric::Policies::Value
- Inherits:
-
Object
- Object
- Parametric::Policies::Value
- Defined in:
- lib/parametric/policies.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #coerce(_value, _key, _context) ⇒ Object
- #eligible?(value, key, payload) ⇒ Boolean
-
#initialize(val, msg = 'invalid value') ⇒ Value
constructor
A new instance of Value.
- #meta_data ⇒ Object
- #valid?(value, key, payload) ⇒ Boolean
Constructor Details
#initialize(val, msg = 'invalid value') ⇒ Value
Returns a new instance of Value.
35 36 37 38 |
# File 'lib/parametric/policies.rb', line 35 def initialize(val, msg = 'invalid value') @message = msg @val = val end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
33 34 35 |
# File 'lib/parametric/policies.rb', line 33 def @message end |
Instance Method Details
#coerce(_value, _key, _context) ⇒ Object
44 45 46 |
# File 'lib/parametric/policies.rb', line 44 def coerce(_value, _key, _context) @val end |
#eligible?(value, key, payload) ⇒ Boolean
40 41 42 |
# File 'lib/parametric/policies.rb', line 40 def eligible?(value, key, payload) payload.key?(key) end |
#meta_data ⇒ Object
52 53 54 |
# File 'lib/parametric/policies.rb', line 52 def { value: @val } end |
#valid?(value, key, payload) ⇒ Boolean
48 49 50 |
# File 'lib/parametric/policies.rb', line 48 def valid?(value, key, payload) !payload.key?(key) || !!(value == @val) end |