0

Gem AASM supports multiple state machine per class with verion 4.3 or above. A unique state machine selector is used for each state machine in one class. Can one state appear in multiple state machine?

Here is an example. The state walking appears in both :move and :work. Is state walking all right? Or I have to name differently like: state walking_move and state waling_work.

class SimpleMultipleExample
  include AASM
  aasm(:move) do
    state :standing, :initial => true
    state :walking  #<====

    event :walk do
      transitions :from => :standing, :to => :walking
    end
  end

  aasm(:work) do
    state :sleeping, :initial => true
    state :walking  #<====

    event :start do
      transitions :from => :sleeping, :to => :walking
    end
  end
end

Also can all initial state be the same such as initial_state in different state machine?

user938363
  • 9,990
  • 38
  • 137
  • 303
  • If you run this it gives a warning. `WARN -- : SimpleMultipleExample: overriding method 'walking?'!`. I'm not sure why you would want several state machines sharing a state in the same class? – user1875195 Feb 03 '17 at 22:39
  • The warning is ONLY for event. There is no mention for same state which is the question here. – user938363 Feb 03 '17 at 22:55

0 Answers0