aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/execution.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activejob/lib/active_job/execution.rb')
-rw-r--r--activejob/lib/active_job/execution.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/activejob/lib/active_job/execution.rb b/activejob/lib/active_job/execution.rb
new file mode 100644
index 0000000000..0e7b5bdd72
--- /dev/null
+++ b/activejob/lib/active_job/execution.rb
@@ -0,0 +1,33 @@
+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 = deserialize_arguments(serialized_args)
+
+ run_callbacks :perform do
+ perform(*arguments)
+ end
+ rescue => exception
+ rescue_with_handler(exception) || raise(exception)
+ end
+
+ def perform(*)
+ fail NotImplementedError
+ end
+
+ private
+ def deserialize_arguments(serialized_args)
+ Arguments.deserialize(serialized_args)
+ end
+
+ end
+end