Sha256: 3c9b1371f66ced61123eb9e762ab5f869acabdd395f263dd8d333912edc6e413

Contents?: true

Size: 737 Bytes

Versions: 9

Compression:

Stored size: 737 Bytes

Contents

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 }

          if component
            component
          else
            raise InvalidComponentIdentifierError, name
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dry-system-0.12.0 lib/dry/system/booter/component_registry.rb
dry-system-0.11.0 lib/dry/system/booter/component_registry.rb
dry-system-0.10.1 lib/dry/system/booter/component_registry.rb
dry-system-0.10.0 lib/dry/system/booter/component_registry.rb
dry-system-0.9.2 lib/dry/system/booter/component_registry.rb
dry-system-0.9.1 lib/dry/system/booter/component_registry.rb
dry-system-0.9.0 lib/dry/system/booter/component_registry.rb
dry-system-0.8.1 lib/dry/system/booter/component_registry.rb
dry-system-0.8.0 lib/dry/system/booter/component_registry.rb