Created
February 4, 2021 00:57
-
-
Save kalashnikovisme/326b11a5c3659989ac067a488ffe93d1 to your computer and use it in GitHub Desktop.
Medium. Get list of state machines names provided by gem `aasm` article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleMultipleExample | |
include AASM | |
aasm(:move, column: 'move_state') do | |
state :standing, initial: true | |
state :walking | |
state :running | |
event :walk do | |
transitions from: :standing, to: :walking | |
end | |
event :run do | |
transitions from: [:standing, :walking], to: :running | |
end | |
event :hold do | |
transitions from: [:walking, :running], to: :standing | |
end | |
end | |
aasm(:work, column: 'work_state') do | |
state :sleeping, initial: true | |
state :processing | |
event :start do | |
transitions from: :sleeping, to: :processing | |
end | |
event :stop do | |
transitions from: :processing, to: :sleeping | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment