Class: Insika::Commands::RestoreDataTool
- Inherits:
-
Object
- Object
- Insika::Commands::RestoreDataTool
- Defined in:
- lib/insika/commands/restore_data_tool.rb
Overview
Restores an old version of a data tool (a new write) and reloads overlay + catalog. The ToolStore raises NotFound/Validation. -> { name, definition (masked) }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(tool_store:, registry:, tool_catalog:, event_stream:) ⇒ RestoreDataTool
constructor
A new instance of RestoreDataTool.
Constructor Details
#initialize(tool_store:, registry:, tool_catalog:, event_stream:) ⇒ RestoreDataTool
Returns a new instance of RestoreDataTool.
11 12 13 14 15 16 |
# File 'lib/insika/commands/restore_data_tool.rb', line 11 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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/insika/commands/restore_data_tool.rb', line 18 def call(command) p = AgentPayload.symbolize(command.payload) name = AgentPayload.presence(p[:name]) raise Insika::ValidationError, "name is required" if name.nil? masked = @tool_store.restore(name, p[:index]) @registry.reload @tool_catalog.reload @event_stream.emit(Insika::Event.new( type: :data_tool_restored, data: { name: name }, meta: { at: Time.now.utc.iso8601 } )) { name: name, definition: masked } end |