Sha256: 283aed05059518c90535bd3dc1d5609a45b1e3139de2111139c789f535e9ddf4

Contents?: true

Size: 628 Bytes

Versions: 4

Compression:

Stored size: 628 Bytes

Contents

# frozen_string_literal: true

module ActiveArchive
  module Methods

    def archivable?
      columns.detect { |col| col.name == 'archived_at' }
    end

    def archive_all(conditions = nil)
      (conditions ? where(conditions) : all).to_a.each(&:archive)
    end

    def archive_all!(conditions = nil)
      (conditions ? where(conditions) : all).to_a.each { |r| r.send(:archive, :force) }
    end

    alias_method :destroy_all!, :archive_all!

    def unarchive_all(conditions = nil)
      (conditions ? where(conditions) : all).to_a.each(&:unarchive)
    end

    alias_method :undestroy_all, :unarchive_all

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_archive-5.3.0 lib/active_archive/methods.rb
active_archive-5.2.2 lib/active_archive/methods.rb
active_archive-5.2.1 lib/active_archive/methods.rb
active_archive-5.2.0 lib/active_archive/methods.rb