Class: Parametric::Policies::Format
- Inherits:
-
Object
- Object
- Parametric::Policies::Format
- 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(fmt, msg = "invalid format") ⇒ Format
constructor
A new instance of Format.
- #meta_data ⇒ Object
- #valid?(value, key, payload) ⇒ Boolean
Constructor Details
#initialize(fmt, msg = "invalid format") ⇒ Format
Returns a new instance of Format.
10 11 12 13 |
# File 'lib/parametric/policies.rb', line 10 def initialize(fmt, msg = "invalid format") @message = msg @fmt = fmt end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/parametric/policies.rb', line 8 def @message end |
Instance Method Details
#coerce(value, key, context) ⇒ Object
19 20 21 |
# File 'lib/parametric/policies.rb', line 19 def coerce(value, key, context) value end |
#eligible?(value, key, payload) ⇒ Boolean
15 16 17 |
# File 'lib/parametric/policies.rb', line 15 def eligible?(value, key, payload) payload.key?(key) end |
#meta_data ⇒ Object
27 28 29 |
# File 'lib/parametric/policies.rb', line 27 def {} end |
#valid?(value, key, payload) ⇒ Boolean
23 24 25 |
# File 'lib/parametric/policies.rb', line 23 def valid?(value, key, payload) !payload.key?(key) || !!(value.to_s =~ @fmt) end |