Sha256: 348f645b9305aff64e034d44fcd51b056dfdfe32d2c9e8d9c342500550d31f3a

Contents?: true

Size: 672 Bytes

Versions: 2

Compression:

Stored size: 672 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.name == name }
        end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-system-0.22.0 lib/dry/system/booter/component_registry.rb
dry-system-0.21.0 lib/dry/system/booter/component_registry.rb