Class: FlatMap::Mapping::Reader::Method

Inherits:
Basic
  • Object
show all
Defined in:
lib/flat_map/mapping/reader/method.rb

Overview

Method mapper calls a method, defined by the mapper, sending the mapping object to it as an argument.

Direct Known Subclasses

Proc

Instance Attribute Summary

Attributes inherited from Basic

#mapping

Instance Method Summary collapse

Constructor Details

#initialize(mapping, method) ⇒ Method

Initialize the reader with a mapping and a method.

Parameters:


12
13
14
# File 'lib/flat_map/mapping/reader/method.rb', line 12

def initialize(mapping, method)
  @mapping, @method = mapping, method
end

Instance Method Details

#readObject

Send the @method to the mapping’s mapper, passing the mapping itself to it.

Returns:

  • (Object)

    value returned by reader


20
21
22
# File 'lib/flat_map/mapping/reader/method.rb', line 20

def read
  mapper.send(@method, mapping)
end