Sha256: 46dc5b55950ba904ce26f2da8aefcafa35978d80caad5cbff20188efc6c863b9

Contents?: true

Size: 612 Bytes

Versions: 7

Compression:

Stored size: 612 Bytes

Contents

# frozen_string_literal: true

module Archival
  class TemplateArray < Array
    alias subscript_access []
    alias subscript_write []=

    def initialize(*args)
      super(*args)
      @data = {}
    end

    def [](*args)
      key = args[0]
      return @data[key] if key.is_a? String
      return @data[key] if key.is_a? Symbol

      subscript_access(*args)
    end

    def []=(*args)
      key = args[0]
      if key.is_a?(String) || key.is_a?(Symbol)
        @data[key] = args[1]
        return
      end
      subscript_write(*args)
    end

    def key?(key)
      @data.key?(key)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
archival-0.0.12 lib/archival/template_array.rb
archival-0.0.11 lib/archival/template_array.rb
archival-0.0.10 lib/archival/template_array.rb
archival-0.0.9 lib/archival/template_array.rb
archival-0.0.8 lib/archival/template_array.rb
archival-0.0.7 lib/archival/template_array.rb
archival-0.0.6 lib/archival/template_array.rb