Sha256: a79e2e408239a0e517203e98eb146503f43c19730143b3c5b0f81d5ee9b04b0b
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require "dry/container" require_relative "initializer" require_relative "types" module ROM # Registry of all known component handlers # # @api public module Components extend Dry::Container::Mixin extend Enumerable module_function # @api private class Handler extend Initializer option :key, type: Types.Instance(Symbol) option :constant, type: Types.Interface(:new) option :namespace, type: Types.Instance(Symbol), default: -> { Inflector.namespace(key) } # @api private def build(**options) constant.new(**options) end end # @see ROM.components # # @return [Components] # # @api public def register(key, constant = nil, **options) Handler.new(key: key, constant: constant, **options).tap do |handler| super(handler.key, handler) # TODO: unify handler access super(handler.namespace, handler) end self end # Iterate over all registered component handlers # # @api public def each keys.each { |key| yield(resolve(key)) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-6.0.0.alpha1 | lib/rom/components.rb |