Class: LinearToonMcp::Tools::Delete
- Defined in:
- lib/linear_toon_mcp/tools/delete.rb
Overview
Base class for delete-mutation tools. Submits the MUTATION constant, asserts the success flag, and returns {“success” => true, “entityId” => …}. The mutation field derives from the class name:
DeleteInitiative.mutation_name # => "initiativeDelete"
Subclasses define the MUTATION constant and override #variables to build the {id:} payload.
Direct Known Subclasses
DeleteComment, DeleteInitiative, RemoveProjectFromInitiative
Class Method Summary collapse
-
.entity(name) ⇒ Object
Overrides the derived entity label.
-
.entity_label ⇒ Object
Returns the entity label for error messages.
-
.entity_name ⇒ Object
Returns the entity name (used to derive Delete.entity_label).
-
.label(name) ⇒ Object
Overrides the derived entity label used in error messages.
-
.mutation(name) ⇒ Object
Overrides the derived GraphQL mutation field name.
-
.mutation_name ⇒ Object
Returns the GraphQL mutation field name.
-
.mutation_string ⇒ Object
Returns the GraphQL mutation — the
MUTATIONconstant on the subclass.
Instance Method Summary collapse
-
#perform(**params) ⇒ Object
Submits Delete.mutation_string with #variables, validates the
successflag, and returns {success: true, entityId: …}. -
#variables ⇒ Object
Subclass hook.
Methods inherited from Base
call, #call, error_response, success_response
Class Method Details
.entity(name) ⇒ Object
Overrides the derived entity label.
22 23 24 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 22 def entity(name) @entity_name = name.to_s end |
.entity_label ⇒ Object
Returns the entity label for error messages.
DeleteInitiative.entity_label # => "Initiative"
44 45 46 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 44 def entity_label @entity_label ||= name.split("::").last.sub(/\ADelete/, "") end |
.entity_name ⇒ Object
Returns the entity name (used to derive entity_label).
37 38 39 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 37 def entity_name @entity_name ||= derive_entity_name end |
.label(name) ⇒ Object
Overrides the derived entity label used in error messages.
27 28 29 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 27 def label(name) @entity_label = name.to_s end |
.mutation(name) ⇒ Object
Overrides the derived GraphQL mutation field name.
17 18 19 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 17 def mutation(name) @mutation_name = name.to_s end |
.mutation_name ⇒ Object
Returns the GraphQL mutation field name.
32 33 34 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 32 def mutation_name @mutation_name ||= "#{entity_name}Delete" end |
.mutation_string ⇒ Object
Returns the GraphQL mutation — the MUTATION constant on the subclass.
49 50 51 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 49 def mutation_string const_get(:MUTATION) end |
Instance Method Details
#perform(**params) ⇒ Object
Submits mutation_string with #variables, validates the success flag, and returns {success: true, entityId: …}.
65 66 67 68 69 70 71 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 65 def perform(**params) data = client.query(self.class.mutation_string, variables: variables(**params)) result = data[self.class.mutation_name] or raise Error, "#{self.class.entity_label} deletion failed: no result returned" raise Error, "#{self.class.entity_label} deletion failed" unless result["success"] {"success" => true, "entityId" => result["entityId"]} end |
#variables ⇒ Object
Subclass hook. Returns the GraphQL {id:} hash for the mutation.
74 75 76 |
# File 'lib/linear_toon_mcp/tools/delete.rb', line 74 def variables(**) raise NotImplementedError, "#{self.class.name} must implement #variables" end |