Class: Rooibos::Command::Exit

Inherits:
Object
  • Object
show all
Includes:
Custom
Defined in:
lib/rooibos/command.rb

Overview

Terminates the application.

Users press a key or click a button to quit. The update function returns a command, and the runtime executes it. Termination is special: the runtime detects this sentinel before dispatching and breaks the loop.

Prefer the Command.exit factory method for convenience.

Example

# Using the factory method (recommended)
[model, Command.exit]

# Using the class directly
[model, Exit.new]

Instance Method Summary collapse

Methods included from Custom

#deconstruct_keys, #rooibos_cancellation_grace_period, #rooibos_command?

Constructor Details

#initializeExit

Ruby 3.x does not auto-freeze zero-member Data.define instances, which prevents Ractor shareability. Explicit freeze is idempotent on 4.0+.



64
65
66
67
# File 'lib/rooibos/command.rb', line 64

def initialize # :nodoc:
  super
  freeze
end

Instance Method Details

#call(_out, _token) ⇒ Object

Stub - Exit is a sentinel handled by runtime before dispatch.



70
71
72
# File 'lib/rooibos/command.rb', line 70

def call(_out, _token)
  raise "Exit command should never be dispatched"
end