[ActiveJob] extract JobBuffer from helper

This commit is contained in:
Abdelkader Boudih 2014-08-29 08:28:07 +00:00
parent 82cb3de461
commit d56caea426
5 changed files with 25 additions and 20 deletions

@ -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

@ -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