Class: AASM::StateMachine
- Inherits:
-
Object
- Object
- AASM::StateMachine
- Defined in:
- lib/alexrevin-aasm_numerical/state_machine.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#events ⇒ Object
Returns the value of attribute events.
-
#initial_state ⇒ Object
Returns the value of attribute initial_state.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#states ⇒ Object
Returns the value of attribute states.
Class Method Summary collapse
Instance Method Summary collapse
- #clone ⇒ Object
- #create_state(name, options) ⇒ Object
-
#initialize(name) ⇒ StateMachine
constructor
A new instance of StateMachine.
Constructor Details
#initialize(name) ⇒ StateMachine
Returns a new instance of StateMachine.
13 14 15 16 17 18 19 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 13 def initialize(name) @name = name @initial_state = nil @states = [] @events = {} @config = OpenStruct.new end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 10 def config @config end |
#events ⇒ Object
Returns the value of attribute events.
10 11 12 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 10 def events @events end |
#initial_state ⇒ Object
Returns the value of attribute initial_state.
10 11 12 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 10 def initial_state @initial_state end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 11 def name @name end |
#states ⇒ Object
Returns the value of attribute states.
10 11 12 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 10 def states @states end |
Class Method Details
.[](clazz) ⇒ Object
2 3 4 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 2 def self.[](clazz) (@machines ||= {})[clazz.to_s] end |
.[]=(clazz, machine) ⇒ Object
6 7 8 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 6 def self.[]=(clazz, machine) (@machines ||= {})[clazz.to_s] = machine end |
Instance Method Details
#clone ⇒ Object
21 22 23 24 25 26 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 21 def clone klone = super klone.states = states.clone klone.events = events.clone klone end |
#create_state(name, options) ⇒ Object
28 29 30 |
# File 'lib/alexrevin-aasm_numerical/state_machine.rb', line 28 def create_state(name, ) @states << AASM::SupportingClasses::State.new(name, ) unless @states.include?(name) end |