Sha256: 49b1e886c95fd24bddf49f14b873460a55ff39bb51d137772f581f32a9f69ea1

Contents?: true

Size: 546 Bytes

Versions: 4

Compression:

Stored size: 546 Bytes

Contents

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

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

          after_create :create_outbox_message!
        end
      end

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

      module ClassMethods
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
outboxer-0.1.3 lib/outboxer/models/outboxable.rb
outboxer-0.1.2 lib/outboxer/models/outboxable.rb
outboxer-0.1.1 lib/outboxer/models/outboxable.rb
outboxer-0.1.0 lib/outboxer/models/outboxable.rb