Sha256: 862b6eee87e6ebec33895402c67ae30df906031d7a580e40af838baac3c93476

Contents?: true

Size: 825 Bytes

Versions: 3

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

module Emittance
  module Resque
    ##
    # The job that is enqueued when an event is emitted.
    #
    class ProcessEventJob
      @queue = :default

      class << self
        def perform(klass_name, method_name, serialized_event)
          deserialized_event = Emittance::Resque::EventSerializer.deserialize(serialized_event)
          new(klass_name, method_name, deserialized_event).perform
        end
      end

      def initialize(klass_name, method_name, event)
        @klass_name = klass_name
        @method_name = method_name
        @event = event
      end

      def perform
        klass.send method_name, event
      end

      private

      attr_reader :klass_name, :method_name, :event

      def klass
        Object.const_get(klass_name)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
emittance-resque-1.1.0 lib/emittance/resque/process_event_job.rb
emittance-resque-1.0.0 lib/emittance/resque/process_event_job.rb
emittance-resque-0.2.0 lib/emittance/resque/process_event_job.rb