Class: Hash
Instance Method Summary collapse
Instance Method Details
#adopt(other) ⇒ Object
30 31 32 |
# File 'lib/reek/smells/smells.rb', line 30 def adopt(other) self.deep_copy.adopt!(other) end |
#adopt!(other) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/reek/smells/smells.rb', line 18 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_copy ⇒ Object
34 35 36 |
# File 'lib/reek/smells/smells.rb', line 34 def deep_copy YAML::load(YAML::dump(self)) end |
#push_keys(hash) ⇒ Object
14 15 16 |
# File 'lib/reek/smells/smells.rb', line 14 def push_keys(hash) keys.each {|key| hash[key].adopt!(self[key]) } end |