Class: Rooibos::Command::Deliver
- Inherits:
-
Object
- Object
- Rooibos::Command::Deliver
- Includes:
- Custom
- Defined in:
- lib/rooibos/command/deliver.rb
Overview
Delivers a message to Update.
Sometimes you have data ready now. A synchronous calculation. A value from the model. You want Update to process it as a message — pattern match on it, use predicates, the whole workflow.
This command wraps any message and delivers it to Update via the runtime.
Use it to send structured messages from Update, or to produce messages from synchronous operations.
Example
Define a message type:
class CacheLoaded < Data.define(:envelope, :data)
include Rooibos::Message::Predicates
end
Send from Update:
in { type: :key, code: "f" }
cache = load_yaml_cache("auth")
Command.deliver(CacheLoaded.new(envelope: :auth, data: cache))
Receive in Update:
in { type: :cache_loaded, envelope: :auth, data: }
model.with(auth: data)
Or use predicates:
elsif message.cache_loaded? and message.auth
model.with(auth: message.data)
Instance Method Summary collapse
-
#call(out, _token) ⇒ Object
Sends the message to the runtime.
Methods included from Custom
#deconstruct_keys, #rooibos_cancellation_grace_period, #rooibos_command?
Instance Method Details
#call(out, _token) ⇒ Object
Sends the message to the runtime.
45 46 47 |
# File 'lib/rooibos/command/deliver.rb', line 45 def call(out, _token) out.put() end |