module Dunlop::WorkflowInstanceModel::ArchivedHandling
  extend ActiveSupport::Concern
  def archived?
    archived_at.present?
  end

  module ClassMethods
    def active
      where(archived_at: nil)
    end

    def archived
      where.not(archived_at: nil)
    end

    def archive!
      update_all(archived_at: Time.now)
    end

    def revive!
      update_all(archived_at: nil)
    end
  end
end
