Class: Representable::Coercion::Coercer
- Inherits:
-
Object
- Object
- Representable::Coercion::Coercer
- Defined in:
- lib/representable/coercion.rb
Instance Method Summary collapse
-
#call(value, doc, 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.
6 7 8 |
# File 'lib/representable/coercion.rb', line 6 def initialize(type) @type = type end |
Instance Method Details
#call(value, doc, 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(value, doc, ) Virtus::Attribute.build(@type).coerce(value) end |