Class: Deltacloud::StateMachine::State
- Inherits:
-
Object
- Object
- Deltacloud::StateMachine::State
- Defined in:
- lib/deltacloud/models/state_machine.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#transitions ⇒ Object
readonly
Returns the value of attribute transitions.
Instance Method Summary collapse
- #from(*states) ⇒ Object
-
#initialize(machine, name) ⇒ State
constructor
A new instance of State.
- #to(destination_name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(machine, name) ⇒ State
Returns a new instance of State.
67 68 69 70 71 |
# File 'lib/deltacloud/models/state_machine.rb', line 67 def initialize(machine, name) @machine = machine @name = name @transitions = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
64 65 66 |
# File 'lib/deltacloud/models/state_machine.rb', line 64 def name @name end |
#transitions ⇒ Object (readonly)
Returns the value of attribute transitions.
65 66 67 |
# File 'lib/deltacloud/models/state_machine.rb', line 65 def transitions @transitions end |
Instance Method Details
#from(*states) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/deltacloud/models/state_machine.rb', line 84 def from(*states) states.each do |s| initial = @machine.state(s) trans = initial.to self.name trans.automatically end end |
#to(destination_name) ⇒ Object
77 78 79 80 81 82 |
# File 'lib/deltacloud/models/state_machine.rb', line 77 def to(destination_name) destination = @machine.state(destination_name) transition = Transition.new( @machine, destination ) @transitions << transition transition end |
#to_s ⇒ Object
73 74 75 |
# File 'lib/deltacloud/models/state_machine.rb', line 73 def to_s self.name.to_s end |