-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix code example in getting started guide #14
Conversation
On a tangent, I had to manually |
a091cfe
to
801f42e
Compare
I've simplified the code so the above comment is now outdated. I reckon the general question still applies though. |
Thanks! |
I'd like to add support for |
Ah ... yeah it's a bit fiddly to specify the full path .... I just tried a few things and got it working as shown in the below commit. Is there any reason we shouldn't do it that way? |
If we start going down that path, it's a model we should adopt everywhere. I'm not sure it's the right path yet. That's my reservation from doing it here. @fxn might have an opinion about it. I know that being explicit is kind of annoying too (pedantic). In other words, if we adopt As an alternative, I'm okay with the top level file, e.g. |
Yeah fair enough 👍 |
Hey! I have done a quick look at the source code. The library is small and most of it is eager loaded, I also see it would be convenient that users do not have to do that Since we are on it, let me share also the way I normally structure my code when it does not use autoload. My main driver is to be intentional about who creates the namespaces: It is the file that naturally defines them. So, my code looks like this: # foo.rb
module Foo # The constant is create here.
require_relative 'foo/bar'
require_relative 'foo/baz'
...
end
# foo/bar.rb
module Foo
class Bar # The constant is created here.
require_relative 'bar/woo'
...
end
end Just sharing for curiosity, not meaning other people should do this :). I like the clarity in the ownership of constant creation, and also allows files downwards to freely choose is they want to define things using a constant path ( (Exception is allowing |
Okay, I've added 1275314 |
The code example in the getting started guide wasn't working for me. It looks like there were some API changes causing it to break. I've amended it to a version that worked for me.
Please let me know if there's a better way to accomplish this. I just hammered at the code until it worked.
Types of Changes
Contribution