Class: FlatMap::Mapping::Writer::Basic

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

Overview

Basic writer simply calls the target’s attribute assignment method passing to it the value being written.

Direct Known Subclasses

Method

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mapping) ⇒ Basic

Initialize writer by passing mapping to it.



11
12
13
# File 'lib/flat_map/mapping/writer/basic.rb', line 11

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/writer/basic.rb', line 6

def mapping
  @mapping
end

Instance Method Details

#write(value) ⇒ Object

Call the assignment method of the target, passing the value to it.

Parameters:

  • value (Object)

Returns:

  • (Object)

    result of assignment



20
21
22
# File 'lib/flat_map/mapping/writer/basic.rb', line 20

def write(value)
  target.send("#{target_attribute}=", value)
end