-
Notifications
You must be signed in to change notification settings - Fork 437
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
Reduce unnecessary external state assignment (singleton
)
#1312
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I'm all in favour for getting rid of this pattern and initializing objects in their contructors
@@ -289,18 +289,16 @@ def handle_meta_method_comment(comment, node) | |||
|
|||
if attributes | |||
attributes.each do |attr| | |||
a = RDoc::Attr.new(@container, attr, rw, processed_comment) | |||
a = RDoc::Attr.new(@container, attr, rw, processed_comment, singleton: @singleton) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know these aren't a part of this PR, but I would really like us to avoid naming variables as a
😅.
Maybe alias_entry
or alias_object
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I'll open a separate PR to expand these short variable names 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Vinicius Stock <[email protected]>
Deploying rdoc with
|
Latest commit: |
7a8045f
|
Status: | ✅ Deploy successful! |
Preview URL: | https://325cef31.rdoc-6cd.pages.dev |
Branch Preview URL: | https://refactor-code-object-constru.rdoc-6cd.pages.dev |
It really bugs me that RDoc has a tendency of assigning a state through a setter immediately after the object's initialization. This makes the dependencies unclear and code unnecessarily verbose.
I'm taking a first step to fix the pattern by passing
singleton
as a constructor argument whenever possible.