Class: Protege::ArchivesController

Inherits:
ApplicationController show all
Includes:
AgentScoped
Defined in:
app/controllers/protege/archives_controller.rb

Overview

Archives and unarchives an agent — the reversible, data-preserving alternative to permanent deletion.

Archiving is modeled as an archive resource on the agent: create archives it (stamps archived_at), destroy unarchives it (clears it). An archived agent stops receiving mail and running scheduled responsibilities, but all its history is kept and it can be restored at any time.

Both actions re-render the agent's action bar in place over Turbo (the sidebar row updates separately via BroadcastableAgent), falling back to a full redirect for non-Turbo requests.

Instance Method Summary collapse

Instance Method Details

#createvoid

This method returns an undefined value.

Archive the agent. Serves POST /agents/:agent_id/archive.



18
19
20
21
22
# File 'app/controllers/protege/archives_controller.rb', line 18

def create
  @agent.archive!

  respond_with_agent(notice: 'Agent archived — it no longer receives mail or runs scheduled tasks.')
end

#destroyvoid

This method returns an undefined value.

Unarchive the agent. Serves DELETE /agents/:agent_id/archive.



27
28
29
30
31
# File 'app/controllers/protege/archives_controller.rb', line 27

def destroy
  @agent.unarchive!

  respond_with_agent(notice: 'Agent restored.')
end