Class: Rooibos::Message::Clock
- Inherits:
-
Object
- Object
- Rooibos::Message::Clock
- Includes:
- Predicates
- Defined in:
- lib/rooibos/message/clock.rb
Overview
Response from a clock command.
Long-lived applications display the time. Dashboards show “last updated 30 seconds ago.” Schedulers fire actions at specific hours. All of these need wall-clock time. But calling Time.now in Update is a side effect—the same model and message produce different results depending on when you call them.
This response carries the wall-clock time from the runtime. Update pattern-matches on the envelope to distinguish multiple clocks.
Use it to handle Command.clock completions.
Example
case msg
in { type: :clock, envelope: :refresh, time: }
[model.with(last_refresh: time), Command.clock(1, :refresh)]
in { type: :clock, envelope: :display, time: }
model.with(current_time: time.utc.to_s)
end
Instance Method Summary collapse
-
#clock? ⇒ Boolean
Returns
truefor clock responses.
Methods included from Predicates
#==, #deconstruct_keys, #method_missing, #respond_to_missing?, #to_sym
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rooibos::Message::Predicates
Instance Method Details
#clock? ⇒ Boolean
Returns true for clock responses.
35 36 37 |
# File 'lib/rooibos/message/clock.rb', line 35 def clock? true end |