lib/outboxable.rb in outboxable-0.1.2 vs lib/outboxable.rb in outboxable-0.1.3
- old
+ new
@@ -1,28 +1,29 @@
# frozen_string_literal: true
-require_relative "outboxable/version"
+require_relative 'outboxable/version'
require 'outboxable/worker'
require 'outboxable/publishing_manager'
require 'outboxable/polling_publisher_worker'
require 'outboxable/connection'
require 'outboxable/configuration'
require 'outboxable/rabbitmq/publisher'
+require 'active_support/concern'
module Outboxable
class Error < StandardError; end
-
+
extend ActiveSupport::Concern
included do
after_create :instantiate_outbox_for_create, if: proc { |object| object.check_outbox_condition(object:, operation: :create) }
after_update :instantiate_outbox_for_update, if: proc { |object| object.check_outbox_condition(object:, operation: :update) }
has_many :outboxes, as: :outboxable, autosave: false
- def instantiate_outbox(routing_key: )
+ def instantiate_outbox(routing_key:)
outboxes.new(
routing_key:,
exchange: Outboxable.configuration.rabbitmq_event_bus_exchange,
payload: as_json
)