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' を使用しています