我正在尝试在 Ruby 中使用 AASM 处理有限状态机。这是我的代码的一部分:
event :Orthography, :before => :to_lowercase do
puts "Check Orthography"
transitions :from => :Initialized, :to => :UniquenessChecked
end
event :Uniqueness do
puts "Check Uniqueness"
transitions :from => :UniquenessChecked, :to => :OrthographyChecked
end
...
def to_lowercase
puts "To lowercase test"
end
我得到了puts日志:
Check Orthography
Check Uniqueness
To lowercase test
但我希望,因为我使用了 before 回调:
To lowercase test
Check Orthography
Check Uniqueness
我如何在活动开始前或参加活动时做某事?