Class: FlatMap::Mapping::Writer::Method

Inherits:
Basic
  • Object
show all
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

Proc

Instance Attribute Summary

Attributes inherited from Basic

#mapping

Instance Method Summary collapse

Constructor Details

#initialize(mapping, method) ⇒ Method

Initialize the writer with a mapping and method name that should be called on the mapping’s mapper.

Parameters:



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.

Parameters:

  • value (Object)

Returns:

  • (Object)

    result of writing



23
24
25
# File 'lib/flat_map/mapping/writer/method.rb', line 23

def write(value)
  mapper.send(@method, mapping, value)
end