Skip to content

DeleteOperation(T) deletes_dependent feature request #635

@BrucePerens

Description

@BrucePerens

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
end

It'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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions