Sha256: 67a92456158084f4c54b58ea9bf2100fb7009083d23559175e6f4b2469167880

Contents?: true

Size: 329 Bytes

Versions: 8

Compression:

Stored size: 329 Bytes

Contents

# frozen_string_literal: true

module Meteoservice
  module NestedHashValue
    def nested_hash_value(obj, key)
      if obj.respond_to?(:key?) && obj.key?(key)
        obj[key]
      elsif obj.respond_to?(:each)
        r = nil

        obj.find { |*a| r = nested_hash_value(a.last, key) }
        r
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
meteoservice-0.2.7 lib/meteoservice/nested_hash_value.rb
meteoservice-0.2.6 lib/meteoservice/nested_hash_value.rb
meteoservice-0.2.5 lib/meteoservice/nested_hash_value.rb
meteoservice-0.2.4 lib/meteoservice/nested_hash_value.rb
meteoservice-0.2.2 lib/meteoservice/nested_hash_value.rb
meteoservice-0.2.1 lib/meteoservice/nested_hash_value.rb
meteoservice-0.2.0 lib/meteoservice/nested_hash_value.rb
meteoservice-0.1.0 lib/meteoservice/nested_hash_value.rb