Sha256: 9071e3d124b70ca5fc3676f8f3297177a10ba07d2b3e7ccf1aac47932805070e
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
# frozen_string_literal: true require "dry/system/constants" module Dry module System # @api private class ProviderSourceRegistry attr_reader :sources def initialize @sources = {} end def load_sources(path) Dir[File.join(path, "**/#{RB_GLOB}")].sort.each do |file| require file end end def register(name:, group:, source:) sources[key(name, group)] = source end def register_from_block(name:, group:, target_container:, &block) register( name: name, group: group, source: Provider::Source.for( name: name, group: group, target_container: target_container, &block ) ) end def resolve(name:, group:) if group == :system Dry::Core::Deprecations.announce( "Providers using `from: :system`", "Use `from: :dry_system` instead", tag: "dry-system", uplevel: 1 ) group = :dry_system end sources[key(name, group)].tap { |source| unless source raise ProviderSourceNotFoundError.new( name: name, group: group, keys: sources.keys ) end } end private def key(name, group) {group: group, name: name} end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-system-0.27.2 | lib/dry/system/provider_source_registry.rb |
dry-system-0.27.1 | lib/dry/system/provider_source_registry.rb |
dry-system-0.27.0 | lib/dry/system/provider_source_registry.rb |