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

activerecord: Add types for create_with to singleton that inherited activerecord base #760

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

Copy link

@dak2 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

activerecord

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

@hibariya, @ksss, @Little-Rubyist, @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.

@dak2 dak2 force-pushed the activerecord/create_with branch 2 times, most recently from 9d97243 to 599024e Compare December 26, 2024 13:41
@@ -1,4 +1,10 @@
module ActiveRecord
class Base
module ClassMethods[Model, Relation, PrimaryKey]
def create_with: (nil | Hash[untyped, untyped]) -> Relation
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you add this to each version? It seems all definitions are the same. I feel it's enough to add this to activerecord.rbs.

Copy link
Contributor Author

@dak2 dak2 Dec 28, 2024

Choose a reason for hiding this comment

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

Thanks for your comment!

I didn't know that if I write rbs in activerecord.rbs, rbs is shared in each version.
I rewrote create_with rbs in activerecord.rbs.

@dak2 dak2 force-pushed the activerecord/create_with branch from 599024e to 0cdedb4 Compare December 28, 2024 08:35
@dak2 dak2 requested a review from tk0miya December 28, 2024 08:40
@@ -51,6 +51,7 @@ module ActiveRecord
def self.create!: (**untyped) -> instance
def self.validate: (*untyped, ?if: condition[instance], ?unless: condition[instance], **untyped) -> void
def self.validates: (*untyped, ?if: condition[instance], ?unless: condition[instance], **untyped) -> void
def self.create_with: (nil | Hash[untyped, untyped]) -> Relation
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 this into ActiveRecord::Base::ClassMethods, please?
And please copy it onto _ActiveRecord_Relation_ClassMethods too.

The rbs_rails gem uses these components and effects the subclasses of ActiveRecord::Base.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed both of them. I did it.
Thanks for your review!

@dak2 dak2 force-pushed the activerecord/create_with branch from 0cdedb4 to 56a0e85 Compare January 5, 2025 07:54
@dak2 dak2 requested a review from tk0miya January 5, 2025 07:59
Copy link
Contributor

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

APPROVE

Thank you for your work!

Copy link

github-actions bot commented Jan 6, 2025

Thanks for your review, @tk0miya!

@dak2, @tk0miya This PR is ready to be merged.
Just comment /merge to merge this PR.

@dak2
Copy link
Contributor Author

dak2 commented Jan 7, 2025

/merge

@github-actions github-actions bot merged commit 7ff8cf6 into ruby:main Jan 7, 2025
7 checks passed
@dak2 dak2 deleted the activerecord/create_with branch January 7, 2025 00:52
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