@@ -27,19 +27,9 @@ class Container < System::Container
2727 #
2828 # @api public
2929 # @!scope class
30- setting :features , %i[ application_contract safe_params controller_helpers ] , reader : true
31-
32- # @overload config.auto_register_paths=(paths)
33- # Set an array of path/block pairs for auto-registration
34- #
35- # This is a low-level setting that typically should not be set explicitly,
36- # use `auto_register!` instead.
37- #
38- # @param paths [Array<Array>]
39- #
40- # @api public
41- # @!scope class
42- setting :auto_register_paths , [ ] . freeze , reader : true
30+ setting :features ,
31+ default : %i[ application_contract safe_params controller_helpers ] ,
32+ reader : true
4333
4434 # @overload config.auto_inject_constant=(auto_inject_constant)
4535 # Set a custom import constant name
@@ -48,7 +38,9 @@ class Container < System::Container
4838 #
4939 # @api public
5040 # @!scope class
51- setting :auto_inject_constant , "Deps" , reader : true
41+ setting :auto_inject_constant ,
42+ default : "Deps" ,
43+ reader : true
5244
5345 # @overload config.container_constant=(container_constant)
5446 # Set a custom container constant
@@ -57,90 +49,16 @@ class Container < System::Container
5749 #
5850 # @api public
5951 # @!scope class
60- setting :container_constant , "Container" , reader : true
52+ setting :container_constant ,
53+ default : "Container" ,
54+ reader : true
6155
6256 # @!endgroup
6357
6458 # The railtie has a rails-specific auto-registrar which is app-dir aware
6559 config . auto_registrar = Rails ::AutoRegistrars ::App
6660
6761 class << self
68- # Set up auto-registration paths and optional a configuration block
69- #
70- # @example set up a single path
71- # Dry::Rails.container do
72- # auto_register!("app/operations")
73- # end
74- #
75- # @example set up a single path with a configuration block
76- # Dry::Rails.container do
77- # auto_register!("app/operations") do |config|
78- # config.exclude do |component|
79- # component.path.start_with?("concerns")
80- # end
81- # end
82- # end
83- #
84- # @example set up multiple paths
85- # Dry::Rails.container do
86- # auto_register!("lib", "app/operations")
87- # end
88- #
89- # @example set up multiple paths with a configuration block
90- # Dry::Rails.container do
91- # # in this case the config block will be applied to all paths
92- # auto_register!("lib", "app/operations") do |config|
93- # config.exclude do |component|
94- # component.path.start_with?("concerns")
95- # end
96- # end
97- # end
98- #
99- # @param paths [Array<String>] One or more paths relative to the root
100- # @param set_load_paths [Boolean] Whether the paths should be added to $LOAD_PATH
101- # @param load_files [Boolean] Whether files should be `required`-ed already
102- #
103- # @return [self]
104- #
105- # @api public
106- #
107- # TODO: this should be moved to dry-system
108- def auto_register! ( *paths , set_load_paths : true , load_files : false , &block )
109- load_paths! ( *paths ) if set_load_paths
110-
111- if load_files
112- paths . each { |path | super ( path , &block ) }
113- else
114- config . auto_register_paths . concat ( paths . product ( [ block ] ) )
115- end
116-
117- self
118- end
119-
120- # Finalize the container
121- #
122- # This is called automatically via the railtie, so typically you won't be using this method
123- # directly
124- #
125- # @param freeze [Boolean] Whether the container should be frozen upon finalization
126- #
127- # @return [self]
128- #
129- # @api public
130- #
131- # TODO: just like auto_register!, this should be moved to dry-system
132- def finalize! ( freeze : false , &block )
133- features . each do |feature |
134- start ( feature )
135- end
136-
137- auto_register_paths . each do |( path , path_block ) |
138- auto_register! ( path , set_load_paths : false , load_files : true , &path_block )
139- end
140-
141- super
142- end
143-
14462 # Return if a given component was booted
14563 #
14664 # @return [Boolean]
0 commit comments