Class: Hash

Inherits:
Object show all
Defined in:
lib/cfoo/parser.rb,
lib/cfoo/processor.rb

Instance Method Summary collapse

Instance Method Details

#deep_merge(other) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/cfoo/processor.rb', line 3

def deep_merge(other)
    merge(other) do |key, our_item, their_item|
        if [our_item, their_item].all? {|item| item.respond_to? :deep_merge }
            our_item.deep_merge(their_item)
        elsif [our_item, their_item].all? {|item| item.respond_to?(:+) && item.respond_to?(:uniq) }
            our_item.concat(their_item).uniq
        else
            their_item
        end
    end
end

#expand_elObject



52
53
54
55
56
# File 'lib/cfoo/parser.rb', line 52

def expand_el
    Hash[map do |key, value|
        [ key, value.expand_el ]
    end]
end