-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creates modules for empty directories #216
Comments
Thanks! :) Yes, this is the way it works. The rules in Zeitwerk are simple: A directory is a namespace, unless you say otherwise. For example, in a Rails application Zeitwerk does not even "peek" at the contents of directories, it is part of the design that it descends level by level strictly. |
I have added documentation about this in 30650ed. Which is your use case? |
Is this "only" due to simplicity, or for some other principled reason?
My use case is the usage of the Cells library. It is a view library, that encourages the creation of components (cells), which are a ruby class + one or more templates. The directory structure is something like this:
This in practice ends up creating lots of empty modules, as this would create
As you can see from my usecase, it is not a whole directory tree that is to be ignored. |
To have clear and simple rules in a somewhat tricky subject: A directory defines a namespace. If you don't want it, you can collapse or ignore, but you do not need to (recursively) peek at their contents. You see the directory, it is a namespace. You ship a gem with a namespace where 3rd-party gems toss constants as plugins. A directory is enough, is simple and consistent. Let me say I totally understand your surprise, this is a trade-off and it is debatable. Regarding
? |
Cells is part of an alternative framework called Trailblazer, which is organized around "concepts". In rails you usually use only the cells part: https://trailblazer.to/2.1/docs/cells.html#cells-rails |
I'd like to think about a solution for your use case. My question is that the documented pattern
is different from your example above
Which pattern should I think about? |
Hm, does it make a difference? In the first case |
I was looking for ignore patterns, and wanted to focus on the exact naming convention for view directories. However, your use case has been the last drop to reconsider this compromise:
This has been implemented in 68976b6. |
Thanks again for maintaining this very important gem! |
Hey! This shipped with the just released 2.6.0. |
I didn't expect that.
Example:
This of course also happens for directories that don't contain any ruby files (eg, contain only erb files). This ends up polluting namespaces a bit.
PS: thanks for this awesome gem!
The text was updated successfully, but these errors were encountered: