Class: Rooibos::Message::Random
- Inherits:
-
Object
- Object
- Rooibos::Message::Random
- Includes:
- Predicates
- Defined in:
- lib/rooibos/message/random.rb
Overview
Response from a random command.
Games roll dice. Encryption needs keys. Shuffling needs seeds. All of these call Kernel#rand or Random. But randomness in Update is a side effect: the same model and message would produce different results on each call. Testing would become fragile.
This response carries the random value from the runtime. Update pattern-matches on the envelope to distinguish multiple rolls.
Use it to handle Command.random completions.
Example
case msg
in { type: :random, envelope: :roll_die, value: }
model.with(roll: value)
in { type: :random, envelope: :shuffle_seed, value: }
model.with(sort_seed: value)
end
Instance Method Summary collapse
-
#random? ⇒ Boolean
Returns
truefor random 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
#random? ⇒ Boolean
Returns true for random responses.
35 36 37 |
# File 'lib/rooibos/message/random.rb', line 35 def random? true end |