Class: Insika::Commands::SeedDemoData
- Inherits:
-
Object
- Object
- Insika::Commands::SeedDemoData
- Defined in:
- lib/insika/commands/seed_demo_data.rb
Overview
Studio/CLI-facing adapter over Insika::Demo::Seeder — the one path both
insika demo:seed and the Studio's "Seed demo data" button use (same
discipline as RunDistillation: one object, two front doors).
Instance Method Summary collapse
-
#call(command) ⇒ Object
payload: { force: bool } -> the seeder's result Hash.
-
#initialize(seeder:, event_stream:) ⇒ SeedDemoData
constructor
A new instance of SeedDemoData.
Constructor Details
#initialize(seeder:, event_stream:) ⇒ SeedDemoData
Returns a new instance of SeedDemoData.
11 12 13 14 |
# File 'lib/insika/commands/seed_demo_data.rb', line 11 def initialize(seeder:, event_stream:) @seeder = seeder @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
payload: { force: bool } -> the seeder's result Hash.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/insika/commands/seed_demo_data.rb', line 17 def call(command) force = Coercion.truthy?(command.payload[:force] || command.payload["force"]) result = @seeder.seed!(force: force) if result[:seeded] @event_stream.emit(Insika::Event.new( type: :demo_data_seeded, data: { agent: result[:agent], counts: result[:counts] }, meta: { at: Time.now.utc.iso8601 } )) end result end |