geekq / workflow

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

Pass event name and args to #persist_workflow_state #178

Closed glasnoster closed 5 years ago

glasnoster commented 8 years ago

I'm using the Vestal Versions gem (https://github.com/laserlemon/vestal_versions) to version user changes in models. I also need to version state changes and attach the user that changed the state to the version change.

I have the user available in the event args. This change basically allows me to do the following:

  def persist_workflow_state(new_state, event, *event_args)
    current_user = event_args[0] && event_args[0][:user]
    self.update_attributes(state: new_state, updated_by: current_user)
  end