Class: CommandTower::Messaging::Handoff::AdvanceCommunication
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Handoff::AdvanceCommunication
- Defined in:
- app/services/command_tower/messaging/handoff/advance_communication.rb
Overview
Owns the handoff write transaction: planned → queued + execution_handoff_status.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(communication:) ⇒ AdvanceCommunication
constructor
A new instance of AdvanceCommunication.
Constructor Details
#initialize(communication:) ⇒ AdvanceCommunication
Returns a new instance of AdvanceCommunication.
12 13 14 |
# File 'app/services/command_tower/messaging/handoff/advance_communication.rb', line 12 def initialize(communication:) @communication = communication end |
Class Method Details
.call(communication:) ⇒ Object
8 9 10 |
# File 'app/services/command_tower/messaging/handoff/advance_communication.rb', line 8 def self.call(communication:) new(communication:).call end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/command_tower/messaging/handoff/advance_communication.rb', line 16 def call ActiveRecord::Base.transaction do @communication.channel_deliveries.each do |delivery| next unless delivery.status == Messaging::ChannelDelivery::STATUS_PLANNED delivery.update!(status: Messaging::ChannelDelivery::STATUS_QUEUED) end next_status = if @communication.channel_deliveries.reload.empty? Messaging::Communication::HANDOFF_COMPLETE else Messaging::Communication::HANDOFF_ENQUEUED end @communication.update!(execution_handoff_status: next_status) end @communication.reload end |