aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_job/execution.rb
blob: 78ada3d908d563bb8408e35a898803df80f45f96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'active_support/rescuable'
require 'active_job/arguments'

module ActiveJob
  module Execution
    extend ActiveSupport::Concern

    included do
      include ActiveSupport::Rescuable
    end

    def execute(job_id, *serialized_args)
      self.job_id    = job_id
      self.arguments = Arguments.deserialize(serialized_args)

      run_callbacks :perform do
        perform *arguments
      end
    rescue => exception
      rescue_with_handler(exception) || raise(exception)
    end

    def perform(*)
      raise NotImplementedError
    end
  end
end