Class: Chutzen::Apply

Inherits:
Object
  • Object
show all
Defined in:
lib/chutzen/apply.rb

Overview

Applies a data hash with values of Chutzen expressions to a destination Dictionary using a deep merge.

Instance Method Summary collapse

Constructor Details

#initialize(target, lookup) ⇒ Apply

Returns a new instance of Apply.



7
8
9
10
# File 'lib/chutzen/apply.rb', line 7

def initialize(target, lookup)
  @target = target
  @lookup = lookup
end

Instance Method Details

#merge(source, path = []) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/chutzen/apply.rb', line 12

def merge(source, path = [])
  case source
  when Hash
    merge_hash(source, path)
  when Array
    merge_array(source, path)
  else
    merge_scalar(source, path)
  end
end