Class: SpreeCmCommissioner::Guests::RefreshDataFillStage

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/guests/refresh_data_fill_stage.rb

Instance Method Summary collapse

Instance Method Details

#call(guest:, notify: true) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/services/spree_cm_commissioner/guests/refresh_data_fill_stage.rb', line 6

def call(guest:, notify: true)
  # incomplete? is always live, so it can't detect a before/after transition on its own —
  # comparing it to itself would always agree. completed? reads the persisted (possibly
  # stale) column instead, which is the actual "before" state worth comparing against.
  was_marked_complete = guest.completed?

  guest.refresh_data_fill_stage

  SpreeCmCommissioner::Guests::SendDynamicFieldNotification.call(guest: guest) if notify && was_marked_complete && guest.incomplete?

  success(guest: guest)
end