Sha256: 35fedc798fee923bfc306be04b7750145e10107c04aa743ecb32879b33200c69

Contents?: true

Size: 262 Bytes

Versions: 6

Compression:

Stored size: 262 Bytes

Contents

Hash.class_eval do

  def nested_fetch(path)
    Array(path).dup.reduce(self) { |current, key| current[key] }
  end

  def nested_delete(path)
    path = Array(path).dup
    last_path_element = path.pop

    nested_fetch(path).delete last_path_element
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hash-pipe-0.5.0 lib/hash_pipe/nested_values.rb
hash-pipe-0.4.1 lib/hash_pipe/nested_values.rb
hash-pipe-0.4.0 lib/hash_pipe/nested_values.rb
hash-pipe-0.3.0 lib/hash_pipe/nested_values.rb
hash-pipe-0.2.0 lib/hash_pipe/nested_values.rb
hash-pipe-0.1.1 lib/hash_pipe/nested_values.rb