[ActiveJob] extract JobBuffer from helper
This commit is contained in:
parent
82cb3de461
commit
d56caea426
@ -28,23 +28,3 @@ def ruby_193?
|
||||
require 'active_support/testing/autorun'
|
||||
|
||||
ActiveJob::Base.logger.level = Logger::DEBUG
|
||||
|
||||
module JobBuffer
|
||||
class << self
|
||||
def clear
|
||||
@buffer = []
|
||||
end
|
||||
|
||||
def add(value)
|
||||
@buffer << value
|
||||
end
|
||||
|
||||
def values
|
||||
@buffer
|
||||
end
|
||||
|
||||
def last_value
|
||||
@buffer.last
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
require_relative '../support/job_buffer'
|
||||
|
||||
class GidJob < ActiveJob::Base
|
||||
def perform(person)
|
||||
JobBuffer.add("Person with ID: #{person.id}")
|
||||
|
@ -1,3 +1,5 @@
|
||||
require_relative '../support/job_buffer'
|
||||
|
||||
class HelloJob < ActiveJob::Base
|
||||
def perform(greeter = "David")
|
||||
JobBuffer.add("#{greeter} says hello")
|
||||
|
@ -1,3 +1,5 @@
|
||||
require_relative '../support/job_buffer'
|
||||
|
||||
class RescueJob < ActiveJob::Base
|
||||
class OtherError < StandardError; end
|
||||
|
||||
|
19
activejob/test/support/job_buffer.rb
Normal file
19
activejob/test/support/job_buffer.rb
Normal file
@ -0,0 +1,19 @@
|
||||
module JobBuffer
|
||||
class << self
|
||||
def clear
|
||||
values.clear
|
||||
end
|
||||
|
||||
def add(value)
|
||||
values << value
|
||||
end
|
||||
|
||||
def values
|
||||
@values ||= []
|
||||
end
|
||||
|
||||
def last_value
|
||||
values.last
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user