Skip to content

Commit

Permalink
Use target_container alias to pass to providers
Browse files Browse the repository at this point in the history
This makes it possible for users of dry-system to provide a subclass of the ProviderRegistrar where they can customise the target_container that their providers receive.
  • Loading branch information
timriley committed May 6, 2024
1 parent 7a7b5a3 commit a1b8a8f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/dry/system/provider_registrar.rb
Expand Up @@ -21,6 +21,9 @@ class ProviderRegistrar
# @api private
attr_reader :container

# @api public
alias_method :target_container, :container

# @api private
def initialize(container)
@providers = {}
Expand Down Expand Up @@ -202,7 +205,7 @@ def build_provider(name, namespace:, source: nil, &block)
Provider.new(
name: name,
namespace: namespace,
target_container: container,
target_container: target_container,
source_class: source_class
)
end
Expand All @@ -213,7 +216,7 @@ def build_provider_from_source(name, source:, group:, namespace:, &block)
Provider.new(
name: name,
namespace: namespace,
target_container: container,
target_container: target_container,
source_class: source_class,
&block
)
Expand Down

0 comments on commit a1b8a8f

Please sign in to comment.