Class: Insika::Commands::DeleteDataTool
- Inherits:
-
Object
- Object
- Insika::Commands::DeleteDataTool
- Defined in:
- lib/insika/commands/delete_data_tool.rb
Overview
Removes a data tool from the ToolStore and reloads overlay + catalog. 404 if it did not exist. -> { name }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(tool_store:, registry:, tool_catalog:, event_stream:) ⇒ DeleteDataTool
constructor
A new instance of DeleteDataTool.
Constructor Details
#initialize(tool_store:, registry:, tool_catalog:, event_stream:) ⇒ DeleteDataTool
Returns a new instance of DeleteDataTool.
10 11 12 13 14 15 |
# File 'lib/insika/commands/delete_data_tool.rb', line 10 def initialize(tool_store:, registry:, tool_catalog:, event_stream:) @tool_store = tool_store @registry = registry @tool_catalog = tool_catalog @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/insika/commands/delete_data_tool.rb', line 17 def call(command) p = AgentPayload.symbolize(command.payload) name = AgentPayload.presence(p[:name]) raise Insika::ValidationError, "name is required" if name.nil? raise Insika::NotFoundError, "tool '#{name}' not found" unless @tool_store.delete(name) @registry.reload @tool_catalog.reload @event_stream.emit(Insika::Event.new( type: :data_tool_deleted, data: { name: name }, meta: { at: Time.now.utc.iso8601 } )) { name: name } end |