如何使 aasm 事件返回布尔值以外的值?我正在使用aasm 2.2.0
例如,有一个 MusicPlayer 模型,它在启动时随机播放一首歌曲
aasm_state :started, :after_enter => :play_song
aasm_state :stopped
aasm_event :start do
:transitions :from => :stopped, :to => :started
end
def play_song
# select and play a song randomly and return the song object
end
现在,如果我想在启动播放器时返回当前正在播放的歌曲,我该如何通过“play_song”方法呢?