Sha256: 9ec9d48797eb46126be3a29bf6c1e24eed127b5192acd73bbefd2d015a13a258
Contents?: true
Size: 715 Bytes
Versions: 1
Compression:
Stored size: 715 Bytes
Contents
class Outbox < ApplicationRecord attribute :allow_publish, :boolean, default: true # Callbacks before_create :set_last_attempted_at before_save :check_publishing after_commit :publish, if: :allow_publish? # Enums enum status: { pending: 0, processing: 1, published: 2, failed: 3 } enum size: { single: 0, batch: 1 } # Validations validates :payload, :exchange, :routing_key, presence: true # Associations belongs_to :outboxable, polymorphic: true, optional: true def set_last_attempted_at self.last_attempted_at = 10.seconds.from_now end def publish Outboxable::Worker.perform_async(id) end def check_publishing self.allow_publish = false if published? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
outboxable-0.1.6 | lib/templates/outbox.rb |