Class: LifecycleVM::VM::Config
- Inherits:
-
Object
- Object
- LifecycleVM::VM::Config
- Defined in:
- lib/lifecycle_vm/vm.rb
Overview
Stores state machine configuration.
Instance Attribute Summary collapse
-
#initial_state ⇒ Symbol
The state to start at.
-
#memory_class ⇒ LifecycleVM::Memory
Not an instance of but the class of the memory for this particular machine.
-
#on_op_failure ⇒ Symbol?
The state to transition to when an op fails.
-
#states ⇒ Hash<Symbol, LifecycleVM::State>
A mapping of state names to state structures.
-
#terminal_states ⇒ Array<Symbol>
A list of state names which the machine will stop at.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
Creates a new Config with default settings.
Constructor Details
#initialize ⇒ Config
Creates a new Config with default settings
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/lifecycle_vm/vm.rb', line 51 def initialize @states = {} @on_op_failure = DEFAULT_ON_OP_FAILURE @initial_state = DEFAULT_START @terminal_states = DEFAULT_TERMINALS @memory_class = LifecycleVM::Memory @terminal_states.each do |state| @states[state] ||= State.new(state, {}) end end |
Instance Attribute Details
#initial_state ⇒ Symbol
Returns the state to start at.
41 42 43 |
# File 'lib/lifecycle_vm/vm.rb', line 41 def initial_state @initial_state end |
#memory_class ⇒ LifecycleVM::Memory
Returns not an instance of but the class of the memory for this particular machine.
48 49 50 |
# File 'lib/lifecycle_vm/vm.rb', line 48 def memory_class @memory_class end |
#on_op_failure ⇒ Symbol?
Returns the state to transition to when an op fails.
35 36 37 |
# File 'lib/lifecycle_vm/vm.rb', line 35 def on_op_failure @on_op_failure end |
#states ⇒ Hash<Symbol, LifecycleVM::State>
Returns a mapping of state names to state structures.
38 39 40 |
# File 'lib/lifecycle_vm/vm.rb', line 38 def states @states end |
#terminal_states ⇒ Array<Symbol>
Returns a list of state names which the machine will stop at.
44 45 46 |
# File 'lib/lifecycle_vm/vm.rb', line 44 def terminal_states @terminal_states end |