-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
My recurrent pattern is that my DeleteOperations look like this:
class DeleteCompany < Avram::DeleteOperation(Company)
before_delete :do_before_delete
def do_before_delete
delete_dependent(record.page!, record.posts!)
end
end...where page is a has_one relationship and post is a has_many. delete_dependent calls the delete operation on every object passed in its arguments, whether they are singular or arrays. This could be done in a macro, for example:
class DeleteCompany < Avram::DeleteOperation(Company)
deletes_dependent :page, :posts
endIt's a little easier in my app because my models provide a #delete_operation(**named_attributes) instance method that returns a new delete operation for that record. There would have to be a naming convention for the delete operation for this to work.
Metadata
Metadata
Assignees
Labels
No labels