Class: Hash

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

Instance Method Summary collapse

Instance Method Details

#recursive_merge!(other) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/bosh_agent/ext.rb', line 26

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

#to_openstructObject



37
38
39
40
41
# File 'lib/bosh_agent/ext.rb', line 37

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