Class: Acts::As::Multiple::StateMachines::SupportingClasses::State
- Inherits:
-
Object
- Object
- Acts::As::Multiple::StateMachines::SupportingClasses::State
- Defined in:
- lib/acts/as/multiple/state_machines/supporting_classes/state.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sm ⇒ Object
readonly
Returns the value of attribute sm.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #entered(record) ⇒ Object
- #entering(record) ⇒ Object
- #exited(record) ⇒ Object
-
#initialize(state_machine, name, options) ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize(state_machine, name, options) ⇒ State
Returns a new instance of State.
10 11 12 13 14 15 16 17 |
# File 'lib/acts/as/multiple/state_machines/supporting_classes/state.rb', line 10 def initialize(state_machine, name, ) @name = name.to_sym @value = ([:value] || @name).to_s @after = Array([:after]) @enter = [:enter] || NOOP @exit = [:exit] || NOOP @sm = state_machine end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/acts/as/multiple/state_machines/supporting_classes/state.rb', line 8 def name @name end |
#sm ⇒ Object (readonly)
Returns the value of attribute sm.
8 9 10 |
# File 'lib/acts/as/multiple/state_machines/supporting_classes/state.rb', line 8 def sm @sm end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/acts/as/multiple/state_machines/supporting_classes/state.rb', line 8 def value @value end |
Instance Method Details
#entered(record) ⇒ Object
23 24 25 |
# File 'lib/acts/as/multiple/state_machines/supporting_classes/state.rb', line 23 def entered(record) @after.each { |action| sm.send(:run_transition_action, record, action) } end |
#entering(record) ⇒ Object
19 20 21 |
# File 'lib/acts/as/multiple/state_machines/supporting_classes/state.rb', line 19 def entering(record) sm.send(:run_transition_action, record, @enter) end |
#exited(record) ⇒ Object
27 28 29 |
# File 'lib/acts/as/multiple/state_machines/supporting_classes/state.rb', line 27 def exited(record) sm.send(:run_transition_action, record, @exit) end |