Sha256: 115634f34baa8284252b1da601a96335f3bf9e4d9e46ace8df76c059aae5f4f7

Contents?: true

Size: 540 Bytes

Versions: 2

Compression:

Stored size: 540 Bytes

Contents

# frozen_string_literal: true

class Hash

  def deep_merge! other
    other.each do |key, value|
      if has_key?(key) && self[key].respond_to?(:deep_merge!)
        self[key].deep_merge! value
      else
        self[key] = value
      end
    end
    self
  end

end

class Array

  def deep_merge! other
    other.each do |value|
      next if self.include?(value)
      next if String === value && self.include?(value.intern)
      next if Symbol === value && self.include?(value.to_s)
      self << value
    end
    self
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inat-get-0.8.0.12 lib/inat/utils/deep.rb
inat-get-0.8.0.11 lib/inat/utils/deep.rb