Sha256: 5019cf432d355df684652752802cf81458160c474da1153d860a232bec193e07

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 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.fetch(name)
    end

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

    private

    def method_missing(name, *args)
      if elements.key?(name)
        self[name]
      else
        super
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.4.2 lib/rom/support/registry.rb