geekq / workflow

Ruby finite-state-machine-inspired API for modeling workflow
MIT License
1.75k stars 207 forks source link

Can I list all events for a particular state through workflow_spec? #196

Closed timeon closed 5 years ago

timeon commented 7 years ago

I ended up with this:

workflow_spec.states.values.collect(&:events).collect(&:keys).flatten.uniq

dapi commented 6 years ago

All available events: current_state.events All enabled events: current_state.events.map { |k, events| events.select { |e| e.condition_applicable? self } }.flatten.uniq.map(&:name)