Sha256: fd29b73ab575e966cfa0697034ef3411389f08df7469954d7b4a34ce0db056c7

Contents?: true

Size: 654 Bytes

Versions: 3

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require "rom/factory/constants"

module ROM
  module Factory
    # @api private
    class Registry
      # @!attribute [r] elements
      #   @return [Hash] a hash with factory builders
      attr_reader :elements

      # @api private
      def initialize
        @elements = {}
      end

      # @api private
      def key?(name)
        elements.key?(name)
      end

      # @api private
      def []=(name, builder)
        elements[name] = builder
      end

      # @api private
      def [](name)
        elements.fetch(name) do
          raise FactoryNotDefinedError, name
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-factory-0.13.0 lib/rom/factory/registry.rb
rom-factory-0.12.0 lib/rom/factory/registry.rb
rom-factory-0.11.0 lib/rom/factory/registry.rb