Sha256: 8dcd0bc4c6de2cce2c20156701a6eae77d9e151b97e60eb15e55133b650985bf

Contents?: true

Size: 472 Bytes

Versions: 6

Compression:

Stored size: 472 Bytes

Contents

module Outboxer
  module Outboxable
    def self.included(base)
      base.extend ClassMethods

      base.class_eval do
        has_one :message, class_name: "::Outboxer::Message", as: :outbox_message,
                          dependent: :destroy

        after_create :create_outbox_message!
      end
    end

    def create_outbox_message!
      Message.create!(message: self, status: Message::STATUS[:unpublished])
    end

    module ClassMethods
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
outboxer-0.1.11 lib/outboxer/outboxable.rb
outboxer-0.1.10 lib/outboxer/outboxable.rb
outboxer-0.1.9 lib/outboxer/outboxable.rb
outboxer-0.1.8 lib/outboxer/outboxable.rb
outboxer-0.1.6 lib/outboxer/outboxable.rb
outboxer-0.1.5 lib/outboxer/outboxable.rb