Class: Hash

Inherits:
Object show all
Defined in:
lib/reek/sniffer.rb

Instance Method Summary collapse

Instance Method Details

#adopt(other) ⇒ Object



36
37
38
# File 'lib/reek/sniffer.rb', line 36

def adopt(other)
  self.deep_copy.adopt!(other)
end

#adopt!(other) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/reek/sniffer.rb', line 24

def adopt!(other)
  other.keys.each do |key|
    ov = other[key]
    if Array === ov and has_key?(key)
      self[key] += ov
    else
      self[key] = ov
    end
  end
  self
end

#deep_copyObject



40
41
42
# File 'lib/reek/sniffer.rb', line 40

def deep_copy
  YAML::load(YAML::dump(self))
end

#push_keys(hash) ⇒ Object



20
21
22
# File 'lib/reek/sniffer.rb', line 20

def push_keys(hash)
  keys.each {|key| hash[key].adopt!(self[key]) }
end