Skip to content

Commit cab4e49

Browse files
committed
Do not load Main App container if its disabled
1 parent 843c503 commit cab4e49

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

lib/dry/rails/finalizer.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
module Dry
44
module Rails
55
class Finalizer
6+
def self.app_namespace_to_name(app_namespace)
7+
app_namespace.name.underscore.to_sym
8+
end
9+
610
def initialize(
711
railtie:,
812
app_namespace:,
@@ -155,7 +159,7 @@ def self.new(
155159
railtie: railtie,
156160
app_namespace: app_namespace,
157161
root_path: root_path,
158-
name: name || app_namespace.name.underscore.to_sym,
162+
name: name || ::Dry::Rails::Finalizer.app_namespace_to_name(app_namespace),
159163
container_const_name: container_const_name,
160164
default_inflector: default_inflector
161165
)

lib/dry/rails/railtie.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ class Railtie < ::Rails::Railtie
1212
# This is needed because `finalize!` can reload code and this hook is called every-time
1313
# in development env upon a request (in production it's called just once during booting)
1414
config.to_prepare do
15-
Railtie.finalize!
15+
Railtie.finalize! if Dry::Rails.config.main_app_enabled
1616
end
1717

1818
initializer "dry-rails.main-app-container" do
19-
Dry::Rails.config.main_app_name = app_namespace.to_s.downcase
19+
Dry::Rails.config.main_app_name = Dry::Rails::Finalizer.app_namespace_to_name(app_namespace)
2020
end
2121

2222
# Code-reloading-aware finalization process
@@ -25,7 +25,6 @@ class Railtie < ::Rails::Railtie
2525
# and registers default components like the railtie itself or the inflector
2626
#
2727
# @api public
28-
#
2928
delegate :finalize!, to: :finalizer
3029
alias_method :reload, :finalize!
3130

@@ -45,12 +44,6 @@ class Railtie < ::Rails::Railtie
4544
# @api public
4645
delegate :container, to: :finalizer
4746

48-
# @api private
49-
delegate :reloading?, to: :finalizer
50-
51-
# @api private
52-
delegate :name, to: :finalizer
53-
5447
# Infer the default application namespace
5548
#
5649
# TODO: we had to rename namespace=>app_namespace because
@@ -74,9 +67,6 @@ def app_namespace
7467
# @api private
7568
delegate :remove_constant, to: :finalizer
7669

77-
# @api private
78-
delegate :container_const_name, to: :finalizer
79-
8070
private
8171

8272
def finalizer

0 commit comments

Comments
 (0)