Class: Fend::Plugins::Coercions::Coercer
- Inherits:
-
Object
- Object
- Fend::Plugins::Coercions::Coercer
- Defined in:
- lib/fend/plugins/coercions.rb
Instance Attribute Summary collapse
-
#coerce ⇒ Object
readonly
Returns the value of attribute coerce.
Instance Method Summary collapse
- #call(data, schema) ⇒ Object
-
#initialize(coerce) ⇒ Coercer
constructor
A new instance of Coercer.
Constructor Details
#initialize(coerce) ⇒ Coercer
Returns a new instance of Coercer.
244 245 246 |
# File 'lib/fend/plugins/coercions.rb', line 244 def initialize(coerce) @coerce = coerce end |
Instance Attribute Details
#coerce ⇒ Object (readonly)
Returns the value of attribute coerce.
242 243 244 |
# File 'lib/fend/plugins/coercions.rb', line 242 def coerce @coerce end |
Instance Method Details
#call(data, schema) ⇒ Object
248 249 250 251 252 253 254 |
# File 'lib/fend/plugins/coercions.rb', line 248 def call(data, schema) data.each_with_object({}) do |(name, value), result| type = schema[name] result[name] = coerce_value(type, value) end end |