Sha256: 4d258d948ccfe9cce5763cb74e42e22fde2491b621eca6c4158005d43d2f70ab

Contents?: true

Size: 460 Bytes

Versions: 7

Compression:

Stored size: 460 Bytes

Contents

#
# Extensions to +Hash+ needed by Reek.
#
class Hash
  def push_keys(hash)
    keys.each {|key| hash[key].adopt!(self[key]) }
  end

  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
  
  def adopt(other)
    self.deep_copy.adopt!(other)
  end
  
  def deep_copy
    YAML::load(YAML::dump(self))
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reek-1.3.1 lib/reek/core/hash_extensions.rb
reek-1.3 lib/reek/core/hash_extensions.rb
reek-1.2.13 lib/reek/core/hash_extensions.rb
reek-1.2.12 lib/reek/core/hash_extensions.rb
reek-1.2.11 lib/reek/core/hash_extensions.rb
reek-1.2.10 lib/reek/core/hash_extensions.rb
reek-1.2.9 lib/reek/core/hash_extensions.rb