Sha256: 8384574bb3e6e6705a1994d712c7caf99e3d506049bdfbe440e6882da38d9bdd

Contents?: true

Size: 476 Bytes

Versions: 3

Compression:

Stored size: 476 Bytes

Contents

# frozen_string_literal: true

require 'delegate'

module WeatherLink
  class HashWrapper < SimpleDelegator
    attr_reader :data

    def initialize(data)
      @data = data
      super
    end

    private

    def method_missing(symbol, *args)
      return data.fetch(symbol.to_s) if data.include?(symbol.to_s)

      super
    end

    def respond_to_missing?(symbol, include_private = false)
      return true if data.include?(symbol.to_s)

      super
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
weatherlink-0.1.3 lib/weatherlink/hash_wrapper.rb
weatherlink-0.1.2 lib/weatherlink/hash_wrapper.rb
weatherlink-0.1.1 lib/weatherlink/hash_wrapper.rb