Class: Protege::AgentToolkitRulesController

Inherits:
ApplicationController show all
Includes:
AgentToolkitScoped
Defined in:
app/controllers/protege/agent_toolkit_rules_controller.rb

Overview

Manages a toolkit grant's allow/deny gate rules — the sender gate for one agent's copy of a toolkit. Nested under the grant via the AgentToolkitScoped concern (which loads @agent_toolkit); mirrors AccessRulesController (Turbo child rows), rendering back to the grant's page.

Instance Method Summary collapse

Instance Method Details

#createvoid

This method returns an undefined value.

Add a gate rule to the grant. Turbo requests append the row and reset the form; non-Turbo requests redirect back to the grant.



16
17
18
19
20
21
22
23
24
# File 'app/controllers/protege/agent_toolkit_rules_controller.rb', line 16

def create
  @agent_toolkit_rule = @agent_toolkit.agent_toolkit_rules.build(rule_params)
  saved               = @agent_toolkit_rule.save

  respond_to do |format|
    format.turbo_stream { render :create, status: saved ? :ok : :unprocessable_entity }
    format.html         { redirect_to agent_toolkit_path(@agent_toolkit), **create_flash(saved) }
  end
end

#destroyvoid

This method returns an undefined value.

Remove a gate rule from the grant. Turbo requests remove the row in place.



29
30
31
32
33
34
35
36
# File 'app/controllers/protege/agent_toolkit_rules_controller.rb', line 29

def destroy
  @agent_toolkit_rule.destroy

  respond_to do |format|
    format.turbo_stream { render turbo_stream: turbo_stream.remove(@agent_toolkit_rule) }
    format.html         { redirect_to agent_toolkit_path(@agent_toolkit), notice: 'Rule removed.' }
  end
end