Class: Insika::Command
- Inherits:
-
Data
- Object
- Data
- Insika::Command
- Defined in:
- lib/insika/command.rb
Overview
Every mutating interaction becomes a Command. Shared shape:
type: Symbol (:create_session, :send_message, :trigger_workflow,
:cancel_task, :resume_task)
payload: Hash validated by the handler
meta: { command_id:, tenant:, transport:, issued_at: }
Command does not validate payload (that's the handler's job) and does not
know about the bus.
Instance Attribute Summary collapse
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.build(type, payload = {}, transport: :internal, tenant: nil) ⇒ Object
Factory that fills in the meta defaults.
Instance Attribute Details
#meta ⇒ Object (readonly)
Returns the value of attribute meta
15 16 17 |
# File 'lib/insika/command.rb', line 15 def @meta end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload
15 16 17 |
# File 'lib/insika/command.rb', line 15 def payload @payload end |
#type ⇒ Object (readonly)
Returns the value of attribute type
15 16 17 |
# File 'lib/insika/command.rb', line 15 def type @type end |
Class Method Details
.build(type, payload = {}, transport: :internal, tenant: nil) ⇒ Object
Factory that fills in the meta defaults. type is
normalized to Symbol; a nil payload becomes {} (the handler decides
whether required fields are missing).
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/insika/command.rb', line 19 def self.build(type, payload = {}, transport: :internal, tenant: nil) new( type: type.to_sym, payload: payload || {}, meta: { command_id: SecureRandom.uuid, tenant: tenant, transport: transport, issued_at: Time.now.utc.iso8601 } ) end |