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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reset_association method signature for singular AR associations #1854

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/tapioca/dsl/compilers/active_record_associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ def populate_single_assoc_getter_setter(klass, association_name, reflection)
"reload_#{association_name}",
return_type: association_type,
)
klass.create_method(
"reset_#{association_name}",
return_type: "void",
)
unless reflection.polymorphic?
klass.create_method(
"build_#{association_name}",
Expand Down
48 changes: 48 additions & 0 deletions spec/tapioca/dsl/compilers/active_record_associations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ def reload_author; end

sig { returns(T.nilable(::Category)) }
def reload_category; end

sig { void }
def reset_author; end

sig { void }
def reset_category; end
end
end
RBI
Expand Down Expand Up @@ -195,6 +201,9 @@ def category_attributes=(attributes); end

sig { returns(T.untyped) }
def reload_category; end

sig { void }
def reset_category; end
end
end
RBI
Expand Down Expand Up @@ -294,6 +303,9 @@ def create_author!(*args, &blk); end

sig { returns(T.nilable(::User)) }
def reload_author; end

sig { void }
def reset_author; end
end
end
RBI
Expand Down Expand Up @@ -557,6 +569,9 @@ def create_author!(*args, &blk); end

sig { returns(T.nilable(::Blog::Author)) }
def reload_author; end

sig { void }
def reset_author; end
end
end
RBI
Expand Down Expand Up @@ -627,6 +642,9 @@ def post=(value); end

sig { returns(T.nilable(::Blog::Core::Post)) }
def reload_post; end

sig { void }
def reset_post; end
end
end
RBI
Expand Down Expand Up @@ -745,6 +763,9 @@ def create_shop!(*args, &blk); end
sig { returns(T.nilable(::Shop)) }
def reload_shop; end

sig { void }
def reset_shop; end

sig { returns(T.nilable(::Shop)) }
def shop; end

Expand Down Expand Up @@ -858,6 +879,12 @@ def reload_author; end

sig { returns(T.nilable(::Category)) }
def reload_category; end

sig { void }
def reset_author; end

sig { void }
def reset_category; end
end
end
RBI
Expand Down Expand Up @@ -897,6 +924,9 @@ def category_attributes=(attributes); end

sig { returns(T.untyped) }
def reload_category; end

sig { void }
def reset_category; end
end
end
RBI
Expand Down Expand Up @@ -996,6 +1026,9 @@ def create_author!(*args, &blk); end

sig { returns(T.nilable(::User)) }
def reload_author; end

sig { void }
def reset_author; end
end
end
RBI
Expand Down Expand Up @@ -1259,6 +1292,9 @@ def create_author!(*args, &blk); end

sig { returns(T.nilable(::Blog::Author)) }
def reload_author; end

sig { void }
def reset_author; end
end
end
RBI
Expand Down Expand Up @@ -1329,6 +1365,9 @@ def post=(value); end

sig { returns(T.nilable(::Blog::Core::Post)) }
def reload_post; end

sig { void }
def reset_post; end
end
end
RBI
Expand Down Expand Up @@ -1447,6 +1486,9 @@ def create_shop!(*args, &blk); end
sig { returns(T.nilable(::Shop)) }
def reload_shop; end

sig { void }
def reset_shop; end

sig { returns(T.nilable(::Shop)) }
def shop; end

Expand Down Expand Up @@ -1524,6 +1566,12 @@ def reload_photo_attachment; end

sig { returns(T.untyped) }
def reload_photo_blob; end

sig { void }
def reset_photo_attachment; end

sig { void }
def reset_photo_blob; end
end
end
RBI
Expand Down
Loading