Sha256: 471892d346c4546de19ea1d1caffb5db2227fe60e5e2918a13bd5cb6c7daf122

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

module ActiveJobChannel
  module Broadcaster
    module ClassMethods
      def active_job_channel
        after_perform :broadcast_success
        rescue_from '::StandardError' do |exception|
          broadcast_failure
          raise exception
        end

        include ActiveJobChannel::Broadcaster::InstanceMethods
      end
    end

    module InstanceMethods
      def broadcast_failure
        ActiveJobChannel::Channel.broadcast_to(
          'active_job_channel',
          status: 'failure',
          job_name: self.class.to_s
        )
      end

      def broadcast_success
        ActiveJobChannel::Channel.broadcast_to(
          'active_job_channel',
          status: 'success',
          job_name: self.class.to_s
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_job_channel-0.0.2 lib/active_job_channel/broadcaster.rb
active_job_channel-0.0.1 lib/active_job_channel/broadcaster.rb