Sha256: d983b7bf543d1baf117c018feb7691e8fc49919f93190d042952ac122e306339

Contents?: true

Size: 656 Bytes

Versions: 13

Compression:

Stored size: 656 Bytes

Contents

class Hash
  def the_reset!(default_value= false)
    base= self
    base.each do |key, v|
      if base[key.to_sym].is_a?(Hash)
        base[key.to_sym]= base[key.to_sym].the_reset!(default_value)
      else
        base[key.to_sym]= default_value
      end
    end
  end

  def the_merge!(hash= nil, default_value= true)
    return self unless hash.is_a?(Hash)
    base= self
    hash.each do |key, v|
      if base[key.to_sym].is_a?(Hash) && hash[key.to_sym].is_a?(Hash)
        base[key.to_sym]= base[key.to_sym].the_merge!(hash[key.to_sym], default_value)
      else
        base[key.to_sym]= default_value
      end
    end
    base.to_hash
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
the_role-1.4.1 lib/the_role/hash.rb
the_role-1.4.0 lib/the_role/hash.rb
the_role-1.3.1 lib/the_role/hash.rb
the_role-1.3.0 lib/the_role/hash.rb
the_role-1.2.1 lib/the_role/hash.rb
the_role-1.2.0 lib/the_role/hash.rb
the_role-1.1.1 lib/the_role/hash.rb
the_role-1.1.0 lib/the_role/hash.rb
the_role-1.0.0 lib/the_role/hash.rb
the_role-0.9.93 lib/the_role/hash.rb
the_role-0.9.92 lib/the_role/hash.rb
the_role-0.9.91 lib/the_role/hash.rb
the_role-0.9.9 lib/the_role/hash.rb