Class: Representable::VirtusCoercion::Coercer
- Inherits:
-
Object
- Object
- Representable::VirtusCoercion::Coercer
- Defined in:
- lib/representable/virtus_coercion.rb
Instance Method Summary collapse
-
#call(input, options) ⇒ Object
This gets called when the :render_filter or :parse_filter option is evaluated.
-
#initialize(type) ⇒ Coercer
constructor
A new instance of Coercer.
Constructor Details
#initialize(type) ⇒ Coercer
Returns a new instance of Coercer.
7 8 9 |
# File 'lib/representable/virtus_coercion.rb', line 7 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.
13 14 15 |
# File 'lib/representable/virtus_coercion.rb', line 13 def call(input, ) Virtus::Attribute.build(@type).coerce(input) end |