Closed tk0miya closed 1 year ago
conflicts with generated .rbs files by
rbs prototype rb
I want to clarify the background problem.
I summarize the problem you described in ruby-jp slack in the following. Please tell me if I misunderstand something.
User.find_by
was conflicted.User.find_by
method in a Ruby file.
rbs prototype rb
._ActiveRecord_Relation_ClassMethods#find_by
User
class.User.find_by
methods conflict.To generalize this problem, the conflict happens if the user defines the same name class method as methods defined in _ActiveRecord_Relation_ClassMethods
into a model class.
This PR does the following things.
The first change is acceptable. I also think the pseudo module is the best approach.
But I'm not sure the 2nd and 3rd changes are necessary. It will work even if the interface is replaced with a module with type parameters. For example:
# Generated RBS
class User < ApplicationRecord
extend ActiveRecord_Relation_ClassMethods[User, ActiveRecord_Relation, Integer]
end
In this case, we have the following advantages.
ActiveRecord_Relation_ClassMethods
module in gem_rbs_collection repository.
What do you think? If you think the 2nd and 3rd changes are necessary, please let me know why.
Sorry for my late response. I did not notice your response...
I'm not sure defining a pseudo module to gem_rbs_collection is okay. But it's a simple way to resolve my problem if acceptable. +1 for choose the 1st way.
I posted https://github.com/ruby/gem_rbs_collection/pull/413 to do this on the gem_rbs_collection side. Thank you!
To avoid conflicts with generated .rbs files by
rbs prototype rb
, this expands_ActiveRecord_Relation_ClassMethods
to the concrete moduleGeneratedFinderClassMethods
. It helps to resolve the conflict in .rbs files.