lib/dry/system/provider_source_registry.rb in dry-system-1.0.1 vs lib/dry/system/provider_source_registry.rb in dry-system-1.1.0.beta1
- old
+ new
@@ -4,10 +4,21 @@
module Dry
module System
# @api private
class ProviderSourceRegistry
+ # @api private
+ class Registration
+ attr_reader :source
+ attr_reader :provider_options
+
+ def initialize(source:, provider_options:)
+ @source = source
+ @provider_options = provider_options
+ end
+ end
+
attr_reader :sources
def initialize
@sources = {}
end
@@ -16,22 +27,22 @@
Dir[File.join(path, "**/#{RB_GLOB}")].sort.each do |file|
require file
end
end
- def register(name:, group:, source:)
- sources[key(name, group)] = source
+ def register(name:, group:, source:, provider_options:)
+ sources[key(name, group)] = Registration.new(
+ source: source,
+ provider_options: provider_options
+ )
end
- def register_from_block(name:, group:, &block)
+ def register_from_block(name:, group:, provider_options:, &block)
register(
name: name,
group: group,
- source: Provider::Source.for(
- name: name,
- group: group,
- &block
- )
+ source: Provider::Source.for(name: name, group: group, &block),
+ provider_options: provider_options
)
end
def resolve(name:, group:)
sources[key(name, group)].tap { |source|