Class: Representable::Coercion::Coercer

Inherits:
Object
  • Object
show all
Defined in:
lib/representable/coercion.rb

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Coercer

Returns a new instance of Coercer.



6
7
8
# File 'lib/representable/coercion.rb', line 6

def initialize(type)
  @type = type
end

Instance Method Details

#call(input, options) ⇒ Object

This gets called when the :render_filter or :parse_filter option is evaluated. Usually the Coercer instance is an element in a Pipeline to allow >1 filters per property.



12
13
14
# File 'lib/representable/coercion.rb', line 12

def call(input, options)
  Virtus::Attribute.build(@type).coerce(input)
end