Sha256: 0ee452a625ec0e0fe5a3775f7a16e46a195c7dfdf7741f9e7a550dae1a80ad39

Contents?: true

Size: 517 Bytes

Versions: 8

Compression:

Stored size: 517 Bytes

Contents

module DestroyedAt
  module HasManyAssociation
    def delete_records(records, method)
      if method == :destroy
        records.each do |r|
          if r.respond_to?(:destroyed_at)
            r.destroy(owner.destroyed_at)
          else
            r.destroy
          end
        end
        update_counter(-records.length) unless inverse_updates_counter_cache?
      else
        super
      end
    end
  end
end

ActiveRecord::Associations::HasManyAssociation.send(:prepend, DestroyedAt::HasManyAssociation)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
destroyed_at-2.1.0 lib/destroyed_at/has_many_association.rb
destroyed_at-2.0.0 lib/destroyed_at/has_many_association.rb
destroyed_at-1.0.2 lib/destroyed_at/has_many_association.rb
destroyed_at-1.0.1 lib/destroyed_at/has_many_association.rb
destroyed_at-1.0.0 lib/destroyed_at/has_many_association.rb
destroyed_at-0.4.0 lib/destroyed_at/has_many_association.rb
destroyed_at-0.3.1 lib/destroyed_at/has_many_association.rb
destroyed_at-0.3.0 lib/destroyed_at/has_many_association.rb