From 9298edd8cbf66d6881ff1b0c095168d0f1fdfc2a Mon Sep 17 00:00:00 2001 From: Alex Ghiculescu Date: Wed, 9 Dec 2020 18:16:57 -0600 Subject: [PATCH] has_many scope can get passed an instance (#284) --- lib/activerecord/all/activerecord.rbi | 2 +- lib/activerecord/all/activerecord_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/activerecord/all/activerecord.rbi b/lib/activerecord/all/activerecord.rbi index 61daf4f7..79896711 100644 --- a/lib/activerecord/all/activerecord.rbi +++ b/lib/activerecord/all/activerecord.rbi @@ -60,7 +60,7 @@ module ActiveRecord::Associations::ClassMethods sig do params( name: Symbol, - scope: T.nilable(T.proc.void), + scope: T.any(T.nilable(T.proc.void), T.nilable(T.proc.params(arg: T.untyped).void)), after_add: AssociationCallback, after_remove: AssociationCallback, anonymous_class: T.nilable(T.any(Symbol, String)), diff --git a/lib/activerecord/all/activerecord_test.rb b/lib/activerecord/all/activerecord_test.rb index 79b10aac..b11c08fa 100644 --- a/lib/activerecord/all/activerecord_test.rb +++ b/lib/activerecord/all/activerecord_test.rb @@ -8,6 +8,7 @@ module ActiveRecordAssociationsTest has_many :people, inverse_of: :person has_many :people, inverse_of: false has_many :people, -> { true }, class_name: "Person" + has_many :people_where_scope_is_called_with_instance, ->(instance) { true }, dependent: :destroy has_many :tracks, dependent: :destroy has_many :comments, dependent: :nullify has_many :tags, as: :taggable