Class: Disposable::Twin::PropertyProcessor
- Inherits:
-
Object
- Object
- Disposable::Twin::PropertyProcessor
- Defined in:
- lib/disposable/twin/property_processor.rb
Overview
This is similar to Representable::Serializer and allows to apply a piece of logic (the block passed to #call) to every twin for this property.
For a scalar property, this will be run once and yield the property’s value. For a collection, this is run per item and yields the item.
Instance Method Summary collapse
- #call(&block) ⇒ Object
-
#initialize(definition, twin) ⇒ PropertyProcessor
constructor
A new instance of PropertyProcessor.
Constructor Details
#initialize(definition, twin) ⇒ PropertyProcessor
Returns a new instance of PropertyProcessor.
7 8 9 |
# File 'lib/disposable/twin/property_processor.rb', line 7 def initialize(definition, twin) @definition, @twin = definition, twin end |
Instance Method Details
#call(&block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/disposable/twin/property_processor.rb', line 11 def call(&block) if @definition[:collection] collection!(&block) else property!(&block) end end |