Class: Fend::Plugins::Coercions::Coercer

Inherits:
Object
  • Object
show all
Defined in:
lib/fend/plugins/coercions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#coerceObject (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