Class: BPS::Coercer

Inherits:
Object
  • Object
show all
Defined in:
lib/bps/coercer.rb

Constant Summary collapse

TRUE_VALUES =
[true, 'TRUE', 'true', 'T', 't', 1, '1'].to_set

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ Coercer

Returns a new instance of Coercer.


9
10
11
12
# File 'lib/bps/coercer.rb', line 9

def initialize(schema)
  validate!(schema)
  @schema = schema
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.


7
8
9
# File 'lib/bps/coercer.rb', line 7

def schema
  @schema
end

Instance Method Details

#coerce(hash) ⇒ Object


14
15
16
# File 'lib/bps/coercer.rb', line 14

def coerce(hash)
  coerce_with(@schema, hash)
end