module Vandal::Destroy

Public Instance Methods

vandal_destroy() click to toggle source
# File lib/vandal.rb, line 7
def vandal_destroy
  @destroying ||= false
  return if @destroying
  @destroying = true
  self.class.transaction do
    self.class.related_associations.each do |association|
      related = send(association[:name])
      related.send("vandal_destroy#{association[:collection] ? '_all' : ''}") if related.present?
    end
    delete
  end
ensure
  @destroying = false
end