Sha256: 4bbd821ac1af6152f6e6dacc03c56525ae12cfc49b1a1f1e763dfe4c57decc74

Contents?: true

Size: 739 Bytes

Versions: 3

Compression:

Stored size: 739 Bytes

Contents

module MoneyS3
  class HashWithAttributes
    def initialize(hash, attributes = nil)
      @hash = hash
      @attributes = attributes if attributes
    end

    def value
      @hash
    end

    def attributes
      @attributes ||= {}
    end

    def attributes=(attributes)
      @attributes = attributes
    end

    def ==(other)
      if other.respond_to?(:value) && other.respond_to?(:attributes)
        value == other.value && other.attributes == attributes
      else
        value == other
      end
    end

    def key?(key)
      value.key? key
    end

    def [](key)
      value[key]
    end

    def []=(key, key_value)
      value[key] = key_value
    end

    def dig(*attrs)
      value.dig(*attrs)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
money_s3-0.10.0 lib/money_s3/hash_with_attributes.rb
money_s3-0.9.0 lib/money_s3/hash_with_attributes.rb
money_s3-0.8.0 lib/money_s3/hash_with_attributes.rb