Class: Hash

Inherits:
Object show all
Defined in:
lib/bosh/director/ext.rb

Instance Method Summary collapse

Instance Method Details

#recursive_merge!(other) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/bosh/director/ext.rb', line 22

def recursive_merge!(other)
  self.merge!(other) do |_, old_value, new_value|
    if old_value.class == Hash && new_value.class == Hash
      old_value.recursive_merge!(new_value)
    else
      new_value
    end
  end
  self
end

#to_openstructObject



33
34
35
36
37
# File 'lib/bosh/director/ext.rb', line 33

def to_openstruct
  mapped = {}
  each { |key, value| mapped[key] = value.to_openstruct }
  OpenStruct.new(mapped)
end