Sha256: 18554e1cb6dae90695b2aed3d06706da022a3e7e21067f1d4cefd53b92933772

Contents?: true

Size: 397 Bytes

Versions: 1

Compression:

Stored size: 397 Bytes

Contents

module Sloth
  module HashHelpers
    def find_all_values_for key
      result = []
      result << self[key]
      self.values.each do |hash_value|
        values = hash_value.is_a?(Array) ? hash_value : [hash_value]
        values.flatten.compact.each do |value|
          result += value.find_all_values_for(key) if value.is_a? Hash
        end
      end
      result.compact
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sloth-rb-0.1.0 lib/sloth/hash_helpers.rb