1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activejob/test/jobs/callback_job.rb
Abdelkader Boudih a75f085941 Add 'activejob/' from commit '14f74a8331f94150dfee653224de8fc837797709'
git-subtree-dir: activejob
git-subtree-mainline: b45b99894a
git-subtree-split: 14f74a8331
2014-08-12 09:17:19 +00:00

32 lines
875 B
Ruby

class CallbackJob < ActiveJob::Base
before_perform ->(job) { job.history << "CallbackJob ran before_perform" }
after_perform ->(job) { job.history << "CallbackJob ran after_perform" }
before_enqueue ->(job) { job.history << "CallbackJob ran before_enqueue" }
after_enqueue ->(job) { job.history << "CallbackJob ran after_enqueue" }
around_perform :around_perform
around_enqueue :around_enqueue
def perform(person = "david")
# NOTHING!
end
def history
@history ||= []
end
# FIXME: Not sure why these can't be declared inline like before/after
def around_perform
history << "CallbackJob ran around_perform_start"
yield
history << "CallbackJob ran around_perform_stop"
end
def around_enqueue
history << "CallbackJob ran around_enqueue_start"
yield
history << "CallbackJob ran around_enqueue_stop"
end
end