Module: CarrierWave::Backgrounder::ORM::ActiveModel

Includes:
Base
Defined in:
lib/backgrounder/orm/activemodel.rb

Instance Method Summary collapse

Instance Method Details

#process_in_background(column, worker = ::CarrierWave::Workers::ProcessAsset) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/backgrounder/orm/activemodel.rb', line 10

def process_in_background(column, worker=::CarrierWave::Workers::ProcessAsset)
  super

  mod = Module.new
  include mod
  mod.module_eval  <<-RUBY, __FILE__, __LINE__ + 1
    def trigger_#{column}_background_processing?
      super && (#{column}_changed? || previous_changes.has_key?(:#{column}) || remote_#{column}_url.present?)
    end
  RUBY
end

#store_in_background(column, worker = ::CarrierWave::Workers::StoreAsset) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/backgrounder/orm/activemodel.rb', line 22

def store_in_background(column, worker=::CarrierWave::Workers::StoreAsset)
  super

  mod = Module.new
  include mod
  mod.module_eval  <<-RUBY, __FILE__, __LINE__ + 1
    def trigger_#{column}_background_storage?
      super && (#{column}_changed? || previous_changes.has_key?(:#{column}) || remote_#{column}_url.present?)
    end
  RUBY
end