Module: CarrierWave::Backgrounder

Includes:
Support::Backends
Defined in:
lib/backgrounder/delay.rb,
lib/backgrounder/railtie.rb,
lib/backgrounder/version.rb,
lib/backgrounder/orm/base.rb,
lib/carrierwave_backgrounder.rb,
lib/backgrounder/orm/activemodel.rb,
lib/backgrounder/orm/data_mapper.rb,
lib/backgrounder/support/backends.rb

Defined Under Namespace

Modules: Delay, ORM, Support Classes: Railtie

Constant Summary collapse

VERSION =
"1.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Support::Backends

included

Class Attribute Details

.worker_klassObject (readonly)

Returns the value of attribute worker_klass.



12
13
14
# File 'lib/carrierwave_backgrounder.rb', line 12

def worker_klass
  @worker_klass
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/carrierwave_backgrounder.rb', line 15

def self.configure
  yield self

  case backend
  when :active_job
    @worker_klass = 'CarrierWave::Workers::ActiveJob'

    require 'active_job'
    require 'backgrounder/workers/active_job/process_asset'
    require 'backgrounder/workers/active_job/store_asset'

    queue_name = queue_options[:queue] || 'carrierwave'

    ::CarrierWave::Workers::ActiveJob::ProcessAsset.class_eval do
      queue_as queue_name
    end
    ::CarrierWave::Workers::ActiveJob::StoreAsset.class_eval do
      queue_as queue_name
    end
  when :sidekiq
    @worker_klass = 'CarrierWave::Workers'

    require 'sidekiq'
    ::CarrierWave::Workers::ProcessAsset.class_eval do
      include ::Sidekiq::Worker
    end
    ::CarrierWave::Workers::StoreAsset.class_eval do
      include ::Sidekiq::Worker
    end
  end
end