I'm using https://github.com/state-machines/state_machines for Rails for storing and doing work before and after a state change of an object.
What I'd like to do is have a single method which can be called in a before_transition for a given set of events, and for a given event, have the method called by the before_transition do something a bit differently.
For example, say the method is called log_state_change, something like:
def log_state_change
case <???>
when "successful"
Rails.logger.info "Successful"
when "failure"
Rails.logger.info "Failure"
when "starting_run"
Rails.logger.info "Starting run"
else
Rails.logger.error "Unknown"
end
I can find no methods that would fit for <???> above. Perhaps someone more familiar with this gem could assist please?