Skip to content
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

Merged
merged 4 commits into from
Mar 15, 2025

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Mar 12, 2025

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.

Copy link
Collaborator

@vinistock vinistock left a 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)
Copy link
Collaborator

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?

Copy link
Member Author

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 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

cloudflare-workers-and-pages bot commented Mar 15, 2025

Deploying rdoc with  Cloudflare Pages  Cloudflare Pages

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

View logs

@st0012 st0012 merged commit ee577ea into master Mar 15, 2025
60 checks passed
@st0012 st0012 deleted the refactor-code-object-constructors branch March 15, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants