Sha256: 4ef51c67b997992e72079d914efa1baa103c5420effae84aac70f6594c72a6ef

Contents?: true

Size: 523 Bytes

Versions: 3

Compression:

Stored size: 523 Bytes

Contents

module ROM

  # @api private
  class Registry
    include Enumerable
    include Equalizer.new(:elements)

    attr_reader :elements

    def initialize(elements = {})
      @elements = elements
    end

    def each(&block)
      return to_enum unless block
      elements.each(&block)
    end

    def [](name)
      elements[name]
    end

    def respond_to_missing?(name, include_private = false)
      key?(name) || super
    end

    private

    def method_missing(name, *args)
      self[name]
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-0.4.1 lib/rom/support/registry.rb
rom-0.4.0 lib/rom/support/registry.rb
rom-0.3.1 lib/rom/support/registry.rb