Sha256: 6151f733703a3270f884a8d60b3b96a05af1b48d2de8c9b7b04aa0e9f8163e05

Contents?: true

Size: 460 Bytes

Versions: 4

Compression:

Stored size: 460 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)
      records(conditions, action: :archive)
    end

    def unarchive_all(conditions = nil)
      records(conditions, action: :unarchive)
    end

    private

    def records(conditions = nil, action:)
      where(conditions).find_each(&action)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_archive-6.1.0 lib/active_archive/methods.rb
active_archive-6.0.2 lib/active_archive/methods.rb
active_archive-6.0.1 lib/active_archive/methods.rb
active_archive-6.0.0 lib/active_archive/methods.rb