Class: Assistant::TechnicalArticleManagementToolBuilder::ReplacementTool

Inherits:
ManagementTool
  • Object
show all
Defined in:
app/services/assistant/technical_article_management_tool_builder.rb

Overview

Creates a genuinely new Article identity. Ordinary editorial updates must
use CreateRevisionTool instead.

Instance Method Summary collapse

Methods inherited from ManagementTool

#initialize

Constructor Details

This class inherits a constructor from Assistant::TechnicalArticleManagementToolBuilder::ManagementTool

Instance Method Details

#execute(id:, reason:, confirm_identity_change:) ⇒ String

Returns JSON replacement snapshot.

Parameters:

  • id (Integer)

    approved source ID

Returns:

  • (String)

    JSON replacement snapshot



618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
# File 'app/services/assistant/technical_article_management_tool_builder.rb', line 618

def execute(id:, reason:, confirm_identity_change:, **)
  safely('replacement') do
    raise ToolError, 'Set confirm_identity_change=true only for a real decommissioning or canonical identity change.' unless confirm_identity_change == true
    raise ToolError, 'Explain why a new Article identity is required.' if reason.blank?

    source = find_article!(id)
    authorize!(:update, source)
    authorize!(:create, ArticleTechnical)
    replacement = source.create_replacement_draft!(author: require_actor!)
    response(
      replacement,
      message: "New-identity successor created because: #{reason}. Source ##{source.id} remains #{source.state} until approval."
    )
  end
end

#nameString

Returns stable tool name.

Returns:

  • (String)

    stable tool name



614
# File 'app/services/assistant/technical_article_management_tool_builder.rb', line 614

def name = 'create_technical_article_replacement'