Class: Rooibos::Message::Timer

Inherits:
Data
  • Object
show all
Includes:
Predicates
Defined in:
lib/rooibos/message/timer.rb

Overview

Response from a timer command.

Timer commands fire after a delay. Pattern matching in UPDATE distinguishes multiple timers. Without structured responses, timers return bare symbols—hard to extend with elapsed time or other metadata.

This response includes the envelope for routing and elapsed time. Include Predicates for safe predicate calls on any message.

Use it to handle Command.wait or Command.tick completions.

Example

case msg
in { type: :timer, envelope: :dismiss }
  model.with(notification: nil)
in { type: :timer, envelope: :animate, elapsed: }
  model.with(frame: next_frame(elapsed))
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Predicates

#==, #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 Attribute Details

#elapsedObject (readonly)

Returns the value of attribute elapsed

Returns:

  • (Object)

    the current value of elapsed



30
31
32
# File 'lib/rooibos/message/timer.rb', line 30

def elapsed
  @elapsed
end

#envelopeObject (readonly)

Returns the value of attribute envelope

Returns:

  • (Object)

    the current value of envelope



30
31
32
# File 'lib/rooibos/message/timer.rb', line 30

def envelope
  @envelope
end

Instance Method Details

#deconstruct_keys(_keys) ⇒ Object

Deconstructs for pattern matching.

Returns a hash with :type, :envelope, and :elapsed.



41
42
43
# File 'lib/rooibos/message/timer.rb', line 41

def deconstruct_keys(_keys)
  { type: :timer, envelope:, elapsed: }
end

#timer?Boolean

Returns true for timer responses.

Returns:

  • (Boolean)


34
35
36
# File 'lib/rooibos/message/timer.rb', line 34

def timer?
  true
end