Class: Agents::UpdateAsPrepared

Inherits:
Update show all
Defined in:
app/my_lib/agents/update_as_prepared.rb

Constant Summary

Constants inherited from Base

Base::WORKER_DELAY_TIME

Instance Attribute Summary

Attributes inherited from Base

#audit_comment, #errors, #executor, #force_update, #owner, #reservation, #reservation_params, #restaurant, #user, #vendor_booking_id

Instance Method Summary collapse

Methods inherited from Update

#execute!, #initialize, #update_booking

Methods included from ErrorType

#fatal_error?, #inventory_error?, #normal_error?, #overwrite_error_type!

Methods inherited from Base

#error_message, #hotline, #inventory_available?, #save_reservation!, #status=

Methods included from SharedJobs

#give_campaign_reward, #send_rating_email

Constructor Details

This class inherits a constructor from Agents::Update

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Agents::Base

Instance Method Details

#after_initializeObject



7
8
9
10
# File 'app/my_lib/agents/update_as_prepared.rb', line 7

def after_initialize
  action = reservation.prepared? ? 'Mark as prepared by owner' : 'Cancel cooking by owner'
  reservation.audit_comment = action
end

#update_booking!Object



12
13
14
15
16
17
18
# File 'app/my_lib/agents/update_as_prepared.rb', line 12

def update_booking!
  save_reservation! validate: false
  reservation.run_callbacks :update

  # Trigger sync for prepared status update (owner operation)
  reservation.trigger_immediate_sync
end