aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-03-02 02:56:53 +1030
committerMatthew Draper <matthew@trebex.net>2016-03-02 02:56:53 +1030
commit541e4abb4b3710a384aefac83cafd0ab878c60bf (patch)
tree55603da9b6f9407a24c68e1d1fd53e109c4131e7 /activejob/lib
parentecdc0fbc872ea734adf29b3f9f3463b916235286 (diff)
parent60b53e9883bfd9f4edb640dbe2de89227b875e09 (diff)
downloadrails-541e4abb4b3710a384aefac83cafd0ab878c60bf.tar.gz
rails-541e4abb4b3710a384aefac83cafd0ab878c60bf.tar.bz2
rails-541e4abb4b3710a384aefac83cafd0ab878c60bf.zip
Merge pull request #23807 from matthewd/executor
Publish AS::Executor and AS::Reloader APIs
Diffstat (limited to 'activejob/lib')
-rw-r--r--activejob/lib/active_job/callbacks.rb5
-rw-r--r--activejob/lib/active_job/execution.rb6
-rw-r--r--activejob/lib/active_job/railtie.rb9
3 files changed, 18 insertions, 2 deletions
diff --git a/activejob/lib/active_job/callbacks.rb b/activejob/lib/active_job/callbacks.rb
index 2b6149e84e..a6591c6a05 100644
--- a/activejob/lib/active_job/callbacks.rb
+++ b/activejob/lib/active_job/callbacks.rb
@@ -17,6 +17,11 @@ module ActiveJob
extend ActiveSupport::Concern
include ActiveSupport::Callbacks
+ class << self
+ include ActiveSupport::Callbacks
+ define_callbacks :execute
+ end
+
included do
define_callbacks :perform
define_callbacks :enqueue
diff --git a/activejob/lib/active_job/execution.rb b/activejob/lib/active_job/execution.rb
index 79d232da4a..7c4151fc90 100644
--- a/activejob/lib/active_job/execution.rb
+++ b/activejob/lib/active_job/execution.rb
@@ -17,8 +17,10 @@ module ActiveJob
end
def execute(job_data) #:nodoc:
- job = deserialize(job_data)
- job.perform_now
+ ActiveJob::Callbacks.run_callbacks(:execute) do
+ job = deserialize(job_data)
+ job.perform_now
+ end
end
end
diff --git a/activejob/lib/active_job/railtie.rb b/activejob/lib/active_job/railtie.rb
index b249ec09dd..a47caa4a7e 100644
--- a/activejob/lib/active_job/railtie.rb
+++ b/activejob/lib/active_job/railtie.rb
@@ -19,5 +19,14 @@ module ActiveJob
end
end
+ initializer "active_job.set_reloader_hook" do |app|
+ ActiveSupport.on_load(:active_job) do
+ ActiveJob::Callbacks.singleton_class.set_callback(:execute, :around, prepend: true) do |_, inner|
+ app.reloader.wrap do
+ inner.call
+ end
+ end
+ end
+ end
end
end