ゲームの状態を処理するプログラムにクラスがあります。私は実際にAASMで処理しているので、イベントを作成するにはaasm_event :name ...
、クラス内のようなものを使用する必要があります。
クラスにイベントと状態を動的に追加する必要がある他のファイルをロードできる必要があります。
どうしてそれは可能ですか?
前もって感謝します。
が保護されているかプライベートでない限りaasm_state
、以下は機能するはずです。aasm_event
# 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