Module: HandleParanoiaDestroyedInBelongsToAssociation

Defined in:
lib/paranoia/active_record_5_2.rb

Instance Method Summary collapse

Instance Method Details

#handle_dependencyObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/paranoia/active_record_5_2.rb', line 2

def handle_dependency
  return unless load_target

  case options[:dependent]
  when :destroy
    target.destroy
    if target.respond_to?(:paranoia_destroyed?)
      raise ActiveRecord::Rollback unless target.paranoia_destroyed?
    else
      raise ActiveRecord::Rollback unless target.destroyed?
    end
  else
    target.send(options[:dependent])
  end
end