Hey,
some releases ago it was possible to configure the source_dirs:
comprehensive-source-dirs-configuration-for-advanced-users.
This possibility seems no longer available in this way. Does somebody know, how to achieve this with latest Hanami 2.x?
I want to add something like that:
config.component_dirs.add "app" do |dir|
dir.instance = proc do |component|
if component.identifier.include?("entities")
component.loader.constant(component)
else
component.loader(component)
end
end
end
Thanks
Removed in this PR. You can use config.no_auto_register_paths
or magic comments to exclude certain files.
1 Like
You should still be able to configure component dirs, but inside a prepare_container
block.
The idea with prepare_container
is to give people a “use at your own risk” method for customising internal container config.
The block is run after Hanami has already configured its containers.
So you could try something like this:
module MyApp
class App < Hanami::App
prepare_container do |container|
# container is the Dry::System::Container for the app
# configure an automatically-configured dir like this
container.config.component_dirs.dir("some/dir") do |dir|
# configure the dir here
end
# or add your own
container.config.component_dirs.add "another/dir" do |dir|
end
# or do any other kind of config you want
end
end
end
1 Like
@timriley Thank you. I’m still not used to the awesomeness that hanami offers. I’m still excited every day.
2 Likes