Explicit vs. Implicit Event Transitions
masterIn state_machine, events can be triggered in two ways:
- Explicit Transitions: Calling the instance method generated by the event name (e.g.,
vehicle.ignite). This is the standard approach. - Implicit Transitions: Setting a special state event attribute (e.g.,
vehicle.state_event = 'ignite') and then invoking the action associated with the state machine (e.g.,vehicle.save). This is particularly useful for integrations like ActiveRecord or when driving transitions via a web API.
Note: For implicit transitions, check your specific integration's API documentation for the exact attribute name used.
# Explicit
vehicle.ignite
# Implicit (ActiveRecord example)
vehicle.state_event = 'ignite'
vehicle.save