Class: Spree::StateChangeTrackingJob
- Defined in:
- app/jobs/spree/state_change_tracking_job.rb
Overview
Background job to track state changes asynchronously This avoids performance impact during checkout and prevents callback-related issues with recent versions of the state_machines gem.
Instance Method Summary collapse
Instance Method Details
#perform(stateful, previous_state, current_state, transition_timestamp, name = stateful.class.model_name.element) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/jobs/spree/state_change_tracking_job.rb', line 14 def perform( stateful, previous_state, current_state, , name = stateful.class.model_name.element ) Spree::StateChange.create!( name: name, stateful: stateful, previous_state: previous_state, next_state: current_state, created_at: , updated_at: , user_id: stateful.try(:user_id) || stateful.try(:order)&.user_id ) end |