Class: Insika::Commands::DeleteGolden
- Inherits:
-
Object
- Object
- Insika::Commands::DeleteGolden
- Defined in:
- lib/insika/commands/write_golden.rb
Overview
Control command: removes an eval case. The corpus on disk is the way back
(insika evals:import), which is why this needs no version history.
-> { id, existed }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(golden_store:, event_stream:) ⇒ DeleteGolden
constructor
A new instance of DeleteGolden.
Constructor Details
#initialize(golden_store:, event_stream:) ⇒ DeleteGolden
Returns a new instance of DeleteGolden.
41 42 43 44 |
# File 'lib/insika/commands/write_golden.rb', line 41 def initialize(golden_store:, event_stream:) @goldens = golden_store @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/insika/commands/write_golden.rb', line 46 def call(command) p = AgentPayload.symbolize(command.payload) id = AgentPayload.presence(p[:id]) raise Insika::ValidationError, "id is required" if id.nil? existed = @goldens.delete(id) @event_stream.emit(Insika::Event.new(type: :golden_deleted, data: { id: id, existed: existed }, meta: { at: Time.now.utc.iso8601 })) { id: id, existed: existed } end |