Class: CarrierWave::Workers::StoreAsset

Inherits:
Base
  • Object
show all
Defined in:
lib/backgrounder/workers/store_asset.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#column, #id, #klass

Instance Method Summary collapse

Methods inherited from Base

perform

Instance Attribute Details

#cache_pathObject (readonly)

Returns the value of attribute cache_path.



6
7
8
# File 'lib/backgrounder/workers/store_asset.rb', line 6

def cache_path
  @cache_path
end

#tmp_directoryObject (readonly)

Returns the value of attribute tmp_directory.



6
7
8
# File 'lib/backgrounder/workers/store_asset.rb', line 6

def tmp_directory
  @tmp_directory
end

Instance Method Details

#perform(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/backgrounder/workers/store_asset.rb', line 8

def perform(*args)
  record = super(*args)

  if record.send(:"#{column}_tmp")
    store_directories(record)
    record.send :"process_#{column}_upload=", true
    record.send :"#{column}_tmp=", nil
    record.send :"#{column}_processing=", nil if record.respond_to?(:"#{column}_processing")
    File.open(cache_path) { |f| record.send :"#{column}=", f }
    if record.save!
      FileUtils.rm_r(tmp_directory, :force => true)
    end
  end
end