Ruby zeitwerk: Difference between revisions

From wikinotes
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
ruby auto import/require module.
ruby auto import/require module.<br>
 
Used by default starting in [[ruby rails]] 6.
Used by default starting in [[ruby rails]] 6.


Instead of
<syntaxhighlight lang="ruby">
<syntaxhighlight lang="ruby">
# Instead of
require "foo/bar/baz"
require "foo/bar/baz"
baz = Foo::Bar::Baz.new
baz = Foo::Bar::Baz.new
</syntaxhighlight>


you can just
# You can just
<syntaxhighlight lang="ruby">
baz = Foo::Bar::Baz.new
baz = Foo::Bar::Baz.new
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 01:27, 29 July 2023

ruby auto import/require module.
Used by default starting in ruby rails 6.

# Instead of
require "foo/bar/baz"
baz = Foo::Bar::Baz.new

# You can just
baz = Foo::Bar::Baz.new

Documentation

github https://github.com/fxn/zeitwerk

Notes

zeitwerk configuration
zeitwerk outside of rails