Sha256: 93e1054d7cdc062e5c527ba36296d0657452267ae24fe3c2e4c6126dff1bc99b
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true require "dry/system" Dry::Effects.load_extensions(:auto_inject) module Dry module Effects module System class AutoRegistrar < ::Dry::System::AutoRegistrar # Always memoize and freeze registered components def call(component_dir) component_dir.each_component do |component| next unless register_component?(component) container.register(component.key, memoize: true) { component.instance.freeze } end end end class Container < ::Dry::System::Container setting :auto_registrar, default: AutoRegistrar def self.injector(effects: true, **kwargs) if effects ::Dry::Effects.AutoInject(**kwargs) else super() end end def self.finalize! return self if finalized? super # Force all components to load each_key { resolve(_1) } self end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-effects-0.5.0 | lib/dry/effects/extensions/system.rb |