Class: FiniteMachine::ChoiceMerger
- Inherits:
-
Object
- Object
- FiniteMachine::ChoiceMerger
- Defined in:
- lib/finite_machine/choice_merger.rb
Overview
A class responsible for merging choice options
Instance Method Summary collapse
-
#choice(to, conditions = {}) ⇒ FiniteMachine::Transition
(also: #default)
Create choice transition.
-
#initialize(machine, name, transitions = {}) ⇒ ChoiceMerger
constructor
private
Initialize a ChoiceMerger.
Constructor Details
#initialize(machine, name, transitions = {}) ⇒ ChoiceMerger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a ChoiceMerger
16 17 18 19 20 |
# File 'lib/finite_machine/choice_merger.rb', line 16 def initialize(machine, name, transitions = {}) @machine = machine @name = name @transitions = transitions end |
Instance Method Details
#choice(to, conditions = {}) ⇒ FiniteMachine::Transition Also known as: default
Create choice transition
37 38 39 40 41 |
# File 'lib/finite_machine/choice_merger.rb', line 37 def choice(to, conditions = {}) transition_builder = TransitionBuilder.new(@machine, @name, @transitions.merge(conditions)) transition_builder.call(@transitions[:from] => to) end |