Class: LunaPark::Mappers::Codirectional::Copyists::Slice
- Inherits:
-
Object
- Object
- LunaPark::Mappers::Codirectional::Copyists::Slice
- Defined in:
- lib/luna_park/mappers/codirectional/copyists/slice.rb
Overview
Copyist for copiyng value between two schemas with SAME and PLAIN paths
Instance Method Summary collapse
- #add_key(key) ⇒ Object
- #from_row(row:, attrs:) ⇒ Object
-
#initialize ⇒ Slice
constructor
A new instance of Slice.
- #to_row(row:, attrs:) ⇒ Object
Constructor Details
#initialize ⇒ Slice
Returns a new instance of Slice.
9 10 11 |
# File 'lib/luna_park/mappers/codirectional/copyists/slice.rb', line 9 def initialize @keys = [] end |
Instance Method Details
#add_key(key) ⇒ Object
13 14 15 |
# File 'lib/luna_park/mappers/codirectional/copyists/slice.rb', line 13 def add_key(key) @keys << key end |
#from_row(row:, attrs:) ⇒ Object
17 18 19 |
# File 'lib/luna_park/mappers/codirectional/copyists/slice.rb', line 17 def from_row(row:, attrs:) attrs.merge! row.slice(*@keys) end |
#to_row(row:, attrs:) ⇒ Object
21 22 23 |
# File 'lib/luna_park/mappers/codirectional/copyists/slice.rb', line 21 def to_row(row:, attrs:) row.merge! attrs.slice(*@keys) end |