Skip to content

Commit

Permalink
Revert eager_load option in Container#finalize! (fix #281)
Browse files Browse the repository at this point in the history
First, this is a breaking change that I failed to foresee. We can discuss re-adding it in a less impactful manner, e.g. setting it to false by default. For now I just roll it back.
  • Loading branch information
flash-gordon committed Jan 8, 2025
1 parent 30fcff0 commit 7b8ae92
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 62 deletions.
4 changes: 1 addition & 3 deletions lib/dry/system/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def finalized?
# @return [self] frozen container
#
# @api public
def finalize!(freeze: true, eager_load: true, &)
def finalize!(freeze: true, &)
return self if finalized?

configured!
Expand All @@ -324,8 +324,6 @@ def finalize!(freeze: true, eager_load: true, &)

[providers, auto_registrar, manifest_registrar, importer].each(&:finalize!)

keys.each { resolve(_1) } if eager_load

@__finalized__ = true

self.freeze if freeze
Expand Down
31 changes: 0 additions & 31 deletions spec/integration/container/auto_registration/eager_loading_spec.rb

This file was deleted.

4 changes: 0 additions & 4 deletions spec/integration/container/auto_registration/memoize_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class Test::Container < Dry::System::Container
dir.namespaces.add "test", key: nil
dir.memoize = true
end

config.inflector = Dry::Inflector.new { |i| i.acronym("ABC") }
end
end
end
Expand Down Expand Up @@ -54,8 +52,6 @@ class Test::Container < Dry::System::Container
!component.key.match?(/bar/)
end
end

config.inflector = Dry::Inflector.new { |i| i.acronym("ABC") }
end
end
end
Expand Down
24 changes: 0 additions & 24 deletions spec/unit/container/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,5 @@ def hooks_trace
.from([])
.to [:after_configure]
end

it "raises error for undefined constant (due to inflector missing acronym)" do
expect {
container.configure do |config|
config.root = SPEC_ROOT.join("fixtures").realpath
config.component_dirs.add "components" do |dir|
dir.namespaces.add "test", key: nil
end
end
container.finalize!
}.to raise_error(Dry::System::ComponentNotLoadableError)
end

it "does not raises error for undefined constant when eager_load is false" do
expect {
container.configure do |config|
config.root = SPEC_ROOT.join("fixtures").realpath
config.component_dirs.add "components" do |dir|
dir.namespaces.add "test", key: nil
end
end
container.finalize!(eager_load: false)
}.to_not raise_error
end
end
end

0 comments on commit 7b8ae92

Please sign in to comment.