Open Intrepidd opened 3 years ago
it looks like it works if I write he name-spaced class like this :
module Bar
class Baz
end
end
Could we make it work for the class Bar::Baz
format as well ? Happy to help if you give me pointers on how to implement it
Definition works with nested namespaces as long as all the namespaces are defined. Example:
class Foo
end
module Bar
end
class Bar::Baz
end
Bar::Baz # <- Definition of `Baz` works
I'm not sure if this behavior should be changed, since it accurately reflects runtime behavior. Running the following code results in a NameError
:
class Foo
end
class Bar::Baz # <- uninitialized constant Bar (NameError)
end
With rails and the Zeitwerk loader modules can be defined on the fly
However for several reasons I decided to not write my modules this way anymore, so I no longer require this feature.
Feel free to close if you choose not to go this way :)
Understood. That seems like a good candidate for an optional feature, or possibly a separate extension.
I'll keep this open at least until I create a new issue for the implementation.
@castwide I am facing the same issue on a rails project. Do let me know in what would this take to implement.
I can try from my side on code and testing.
We use inline class definitions (without prior module definitions) in our projects as well. Having this feature would be incredibly useful.
This bit us as well. Some sort of Zeitwerk support would be super. Now we need to remember to add these "old school" empty namespace module definition files all over just for this. E.g.:
$ cat packages/core.rb
module Core
end
We have the same style in rails projects. We need this feature too. Have some issue opened for this feature?
Jumping to a class works fine, however it won't work if the class is within a namespace :
However, the definitions are visible within the symbols :