class Ticket
include AASM
state :new
state :open
state :closed
event :open do
transitions :from => :new,:to => :closed, :guard => :cancelled?
transitions :from => :new,:to => :open, :guard => !:cancelled?
end
def cancelled?
true
end
def not_cancelled?
true
end
end
##Would I need the below?
transitions :from => :new,:to => :open, :guard => :not_cancelled?
为了减少我必须编写的代码量,是否可以在保护函数中使用 !:cancelled 之类的东西?还是我必须单独写一个 not_cancelled?功能(我怀疑是这种情况)。
我正在使用 Ruby 2.1 和 gem 'aasm', '~> 3.1.1'