Class: LunaPark::Mappers::Codirectional::Copyists::Nested

Inherits:
Object
  • Object
show all
Defined in:
lib/luna_park/mappers/codirectional/copyists/nested.rb

Overview

Copyist for copiyng value between two schemas with DIFFERENT or NESTED paths

(Works with only one described attribute)

Instance Method Summary collapse

Constructor Details

#initialize(attrs_path:, row_path:) ⇒ Nested

Returns a new instance of Nested.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
# File 'lib/luna_park/mappers/codirectional/copyists/nested.rb', line 10

def initialize(attrs_path:, row_path:)
  @attrs_path = attrs_path
  @row_path   = row_path

  raise ArgumentError, 'attr path can not be nil'  if attrs_path.nil?
  raise ArgumentError, 'store path can not be nil' if row_path.nil?
end

Instance Method Details

#from_row(row:, attrs:) ⇒ Object



18
19
20
# File 'lib/luna_park/mappers/codirectional/copyists/nested.rb', line 18

def from_row(row:, attrs:)
  copy_nested(from: row, to: attrs, from_path: @row_path, to_path: @attrs_path)
end

#to_row(row:, attrs:) ⇒ Object



22
23
24
# File 'lib/luna_park/mappers/codirectional/copyists/nested.rb', line 22

def to_row(row:, attrs:)
  copy_nested(from: attrs, to: row, from_path: @attrs_path, to_path: @row_path)
end