Class: FlatMap::Mapping::Reader::Basic

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

Overview

Basic reader simply sends a mapped attribute to the target and returns the result value.

Direct Known Subclasses

Formatted, Method

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mapping) ⇒ Basic

Initialize the reader with a mapping.



13
14
15
# File 'lib/flat_map/mapping/reader/basic.rb', line 13

def initialize(mapping)
  @mapping = mapping
end

Instance Attribute Details

#mappingObject (readonly)

Returns the value of attribute mapping.



6
7
8
# File 'lib/flat_map/mapping/reader/basic.rb', line 6

def mapping
  @mapping
end

Instance Method Details

#readObject

Send the attribute method to the target and return its value. As a base class for readers, it allows to pass additional arguments when reading value (for example, used by :enum format of Formatted reader)



23
24
25
# File 'lib/flat_map/mapping/reader/basic.rb', line 23

def read(*)
  target.send(target_attribute)
end