Module: ActiveJob::TestHelper::TestQueueAdapter
Do not use. This module is for internal use only.
| Relationships & Source Files | |
| Defined in: | activejob/lib/active_job/test_helper.rb |
Class Attribute Summary
- .excluded_jobs readonly
- .test_adapter rw
Class Method Summary
Instance Method Summary
Class Attribute Details
.excluded_jobs (readonly)
[ GitHub ]# File 'activejob/lib/active_job/test_helper.rb', line 22
attr_reader :excluded_jobs
.test_adapter (rw)
[ GitHub ]# File 'activejob/lib/active_job/test_helper.rb', line 21
attr_accessor :test_adapter
Class Method Details
.adapter_for(job)
[ GitHub ]# File 'activejob/lib/active_job/test_helper.rb', line 43
def adapter_for(job) return if excluded?(job) if test_adapter test_adapter elsif @adapters[job] @adapters[job] elsif job._queue_adapter.nil? @default_test_adapter ||= ActiveJob::QueueAdapters::TestAdapter.new @adapters[job] ||= @default_test_adapter end end
.compute_excluded(job) (private)
[ GitHub ]# File 'activejob/lib/active_job/test_helper.rb', line 57
def compute_excluded(job) while job <= ActiveJob::Base return true if excluded_jobs.include?(job) job = job.superclass end false end
.exclude(job)
[ GitHub ]# File 'activejob/lib/active_job/test_helper.rb', line 30
def exclude(job) excluded_jobs << job @cache.clear end
.excluded?(job) ⇒ Boolean
# File 'activejob/lib/active_job/test_helper.rb', line 24
def excluded?(job) @cache.fetch(job) do @cache[job] = compute_excluded(job) end end
.reset
[ GitHub ]# File 'activejob/lib/active_job/test_helper.rb', line 35
def reset excluded_jobs.clear @cache.clear @adapters.clear @test_adapter = nil @default_test_adapter = nil end
Instance Method Details
#disable_test_adapter
[ GitHub ]# File 'activejob/lib/active_job/test_helper.rb', line 70
def disable_test_adapter TestQueueAdapter.exclude(self) end
#queue_adapter
[ GitHub ]# File 'activejob/lib/active_job/test_helper.rb', line 66
def queue_adapter TestQueueAdapter.adapter_for(self) || super end