Sha256: 16d8abf2675abdb3297be2135064b9ec04295f12ea0d9a2c4a09e0686a4efd02

Contents?: true

Size: 706 Bytes

Versions: 14

Compression:

Stored size: 706 Bytes

Contents

# frozen_string_literal: true

module Dry
  module System
    class Booter
      class ComponentRegistry
        include Enumerable

        attr_reader :components

        def initialize
          @components = []
        end

        def each(&block)
          components.each(&block)
        end

        def register(component)
          @components << component
        end

        def exists?(name)
          components.any? { |component| component.identifier == name }
        end

        def [](name)
          component = components.detect { |component| component.identifier == name }

          component || raise(InvalidComponentIdentifierError, name)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dry-system-0.20.0 lib/dry/system/booter/component_registry.rb
dry-system-0.19.2 lib/dry/system/booter/component_registry.rb
dry-system-0.18.2 lib/dry/system/booter/component_registry.rb
dry-system-0.19.1 lib/dry/system/booter/component_registry.rb
dry-system-0.19.0 lib/dry/system/booter/component_registry.rb
dry-system-0.18.1 lib/dry/system/booter/component_registry.rb
dry-system-0.18.0 lib/dry/system/booter/component_registry.rb
dry-system-0.17.0 lib/dry/system/booter/component_registry.rb
dry-system-0.15.0 lib/dry/system/booter/component_registry.rb
dry-system-0.14.1 lib/dry/system/booter/component_registry.rb
dry-system-0.14.0 lib/dry/system/booter/component_registry.rb
dry-system-0.13.2 lib/dry/system/booter/component_registry.rb
dry-system-0.13.1 lib/dry/system/booter/component_registry.rb
dry-system-0.13.0 lib/dry/system/booter/component_registry.rb