Refactors code for better readablity

This commit is contained in:
Muhammad Nawzad 2024-05-28 13:51:17 +03:00
parent 035a9822ee
commit 816465eced
No known key found for this signature in database
GPG Key ID: B954B6AAE33940B2

View File

@ -19,18 +19,12 @@ module Outboxable
# Declare a exchange # Declare a exchange
exchange = channel.topic(@resource.exchange, durable: true) exchange = channel.topic(@resource.exchange, durable: true)
content_type = if @resource.respond_to?(:content_type) && @resource.content_type.present?
@resource.content_type
else
'application/json'
end
# Publish the CloudEvent resource to the exchange # Publish the CloudEvent resource to the exchange
exchange.publish( exchange.publish(
to_envelope(resource: @resource), to_envelope(resource: @resource),
routing_key: @resource.routing_key, routing_key: @resource.routing_key,
headers: @resource.try(:headers) || {}, headers: @resource.try(:headers) || {},
content_type: content_type: @resource.try(:content_type) || 'application/json'
) )
# Wait for confirmation # Wait for confirmation