Class: AASM::StateMachine
- Inherits:
-
Object
- Object
- AASM::StateMachine
- Defined in:
- lib/aasm/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.
17 18 19 20 21 22 23 |
# File 'lib/aasm/state_machine.rb', line 17 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.
14 15 16 |
# File 'lib/aasm/state_machine.rb', line 14 def config @config end |
#events ⇒ Object
Returns the value of attribute events.
14 15 16 |
# File 'lib/aasm/state_machine.rb', line 14 def events @events end |
#initial_state ⇒ Object
Returns the value of attribute initial_state.
14 15 16 |
# File 'lib/aasm/state_machine.rb', line 14 def initial_state @initial_state end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/aasm/state_machine.rb', line 15 def name @name end |
#states ⇒ Object
Returns the value of attribute states.
14 15 16 |
# File 'lib/aasm/state_machine.rb', line 14 def states @states end |
Class Method Details
.[](*args) ⇒ Object
5 6 7 |
# File 'lib/aasm/state_machine.rb', line 5 def self.[](*args) (@machines ||= {})[args] end |
.[]=(*args) ⇒ Object
9 10 11 12 |
# File 'lib/aasm/state_machine.rb', line 9 def self.[]=(*args) val = args.pop (@machines ||= {})[args] = val end |
Instance Method Details
#clone ⇒ Object
25 26 27 28 29 |
# File 'lib/aasm/state_machine.rb', line 25 def clone klone = super klone.states = states.clone klone end |
#create_state(name, options) ⇒ Object
31 32 33 |
# File 'lib/aasm/state_machine.rb', line 31 def create_state(name, ) @states << AASM::SupportingClasses::State.new(name, ) unless @states.include?(name) end |