Class: FlatMap::Mapping::Writer::Method
- Defined in:
- lib/flat_map/mapping/writer/method.rb
Overview
Method writer calls a method defined by mapper and sends mapping and value to it as arguments.
Note that this doesn’t set anything on the target itself.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Basic
Instance Method Summary collapse
-
#initialize(mapping, method) ⇒ Method
constructor
Initialize the writer with a
mapping
andmethod
name that should be called on the mapping’s mapper. -
#write(value) ⇒ Object
Write a
value
by sending it, along with the mapping itself.
Constructor Details
#initialize(mapping, method) ⇒ Method
Initialize the writer with a mapping
and method
name that should be called on the mapping’s mapper.
15 16 17 |
# File 'lib/flat_map/mapping/writer/method.rb', line 15 def initialize(mapping, method) @mapping, @method = mapping, method end |
Instance Method Details
#write(value) ⇒ Object
Write a value
by sending it, along with the mapping itself.
23 24 25 |
# File 'lib/flat_map/mapping/writer/method.rb', line 23 def write(value) mapper.send(@method, mapping, value) end |