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

actionpack: Fix helper and fragment_cache_key block to optional #715

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sanfrecce-osaka
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Nov 6, 2024

@sanfrecce-osaka Thanks for your contribution!

Please follow the instructions below for each change.
See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md

Available commands

You can use the following commands by commenting on this PR.

  • /merge: Merge this PR if CI passes

actionpack

You changed RBS files for an existing gem.
You need to get approval from the reviewers of this gem.

@ksss, @tk0miya, please review this pull request.
If this change is acceptable, please make a review comment including APPROVE from here.
Screen Shot 2024-03-19 at 14 13 36

After that, the PR author or the reviewers can merge this PR.
Just comment /merge to merge this PR.

Comment on lines 27 to 29
include Caching
extend AbstractController::Caching::ClassMethods
extend AbstractController::Caching::Fragments::ClassMethods
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to not only extend ClassMethods but also include AbstractController::Caching here.

ActionController::Caching dynamically calls include inside the included block. Therefore it's better to include it explicitly.

https://github.com/rails/rails/blob/v6.0.6.1/actionpack/lib/action_controller/base.rb#L219
https://github.com/rails/rails/blob/v6.0.6.1/actionpack/lib/action_controller/caching.rb#L28-L30
https://github.com/rails/rails/blob/v6.0.6.1/actionpack/lib/abstract_controller/caching.rb#L46

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your feedback, I fixed it in 6b169ec

#
# helper(:three, BlindHelper) { def mice() 'mice' end }
#
def helper: (*untyped args) ?{ () -> untyped } -> untyped
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move the methods only what you changed, please? If my understanding is correct, only ActionController::Helpers::ClassMethods#helper and AbstractController::Caching::Fragments::ClassMethods#fragment_cache_key should be moved and modified.

Copy link
Contributor Author

@sanfrecce-osaka sanfrecce-osaka Nov 9, 2024

Choose a reason for hiding this comment

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

Sorry, I wasn't sure how far I should move the auto-generated code, including comments, so I made sanfrecce-osaka@d7a4fb5 and sanfrecce-osaka@08b92b9 🙏
I fixed in 939ac11 based on your feedback.

…Caching

cf. ruby#715 (comment)

> It would be better to not only extend ClassMethods but also include `AbstractController::Caching` here.
>
> `ActionController::Caching` dynamically calls include inside the included block. Therefore it's better to include it explicitly.
>
> https://github.com/rails/rails/blob/v6.0.6.1/actionpack/lib/action_controller/base.rb#L219 https://github.com/rails/rails/blob/v6.0.6.1/actionpack/lib/action_controller/caching.rb#L28-L30 https://github.com/rails/rails/blob/v6.0.6.1/actionpack/lib/abstract_controller/caching.rb#L46
cf. ruby#715 (comment)

> Could you move the methods only what you changed, please? If my understanding is correct, only `ActionController::Helpers::ClassMethods#helper` and `AbstractController::Caching::Fragments::ClassMethods#fragment_cache_key` should be moved and modified.

revert d7a4fb5 and 08b92b9 excluding 7d95c0d and 1367681
#
# helper(:three, BlindHelper) { def mice() 'mice' end }
#
def helper: (*untyped args) ?{ () -> untyped } -> untyped
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: The above comment describes the argument are Module, Symbol, String. So it would be better to update signature like this:

Suggested change
def helper: (*untyped args) ?{ () -> untyped } -> untyped
def helper: (*Module | Symbol | String args) ?{ () -> void } -> void

Either way, this is off-topic. I'll post another PR after merging this.

@tk0miya
Copy link
Contributor

tk0miya commented Nov 12, 2024

APPROVE

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