Class: Parametric::Policies::Format

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fmt, msg = "invalid format") ⇒ Format

Returns a new instance of Format.



8
9
10
11
# File 'lib/parametric/policies.rb', line 8

def initialize(fmt, msg = "invalid format")
  @message = msg
  @fmt = fmt
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



6
7
8
# File 'lib/parametric/policies.rb', line 6

def message
  @message
end

Instance Method Details

#coerce(value, key, context) ⇒ Object



17
18
19
# File 'lib/parametric/policies.rb', line 17

def coerce(value, key, context)
  value
end

#eligible?(value, key, payload) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/parametric/policies.rb', line 13

def eligible?(value, key, payload)
  payload.key?(key)
end

#meta_dataObject



25
26
27
# File 'lib/parametric/policies.rb', line 25

def 
  {}
end

#valid?(value, key, payload) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/parametric/policies.rb', line 21

def valid?(value, key, payload)
  !payload.key?(key) || !!(value.to_s =~ @fmt)
end