Ruby使用AASM添加动态事件
我在一个程序中有一个类处理游戏状态。我实际上是在用AASM处理它,所以要创建一个事件,我必须在类中使用类似于Ruby使用AASM添加动态事件,ruby,aasm,Ruby,Aasm,我在一个程序中有一个类处理游戏状态。我实际上是在用AASM处理它,所以要创建一个事件,我必须在类中使用类似于AASM\u event:name…的东西 我需要能够加载其他文件,这些文件必须动态地向类添加事件和状态 怎么可能呢 提前感谢。除非aasm_状态和aasm_事件受到保护或保密,否则以下操作应有效: # game.rb class Game include AASM aasm_initial_state :start end # add the require after th
AASM\u event:name…
的东西
我需要能够加载其他文件,这些文件必须动态地向类添加事件和状态
怎么可能呢
提前感谢。除非
aasm_状态
和aasm_事件
受到保护或保密,否则以下操作应有效:
# game.rb
class Game
include AASM
aasm_initial_state :start
end
# add the require after the class definition, else it will complain of a missing constant
require "other_file"
# other_file.rb
Game.aasm_state :another_state
Game.aasm_event do
transitions :to => :another_state, :from => [:start]
end
除非
aasm_状态
和aasm_事件
是受保护的或私有的,否则以下各项应起作用:
# game.rb
class Game
include AASM
aasm_initial_state :start
end
# add the require after the class definition, else it will complain of a missing constant
require "other_file"
# other_file.rb
Game.aasm_state :another_state
Game.aasm_event do
transitions :to => :another_state, :from => [:start]
end