Sha256: d62e8c60a2dee3b7a5511cd50c38b7f2a75d8fac4b2af57ac3f0a450dbf3aa87
Contents?: true
Size: 905 Bytes
Versions: 1
Compression:
Stored size: 905 Bytes
Contents
# encoding: utf-8 module CarrierWave module Workers class StoreAsset < Struct.new(:klass, :id, :column) def self.perform(*args) new(*args).perform end def perform resource = klass.is_a?(String) ? klass.constantize : klass record = resource.find id if tmp = record.send(:"#{column}_tmp") asset = record.send(:"#{column}") cache_dir = [asset.root, asset.cache_dir].join("/") cache_path = [cache_dir, tmp].join("/") tmp_dir = [cache_dir, tmp.split("/")[0]].join("/") record.send :"process_#{column}_upload=", true record.send :"#{column}_tmp=", nil File.open(cache_path) { |f| record.send :"#{column}=", f } if record.save! FileUtils.rm_r(tmp_dir, :force => true) end end end end # StoreAsset end # Workers end # Backgrounder
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
carrierwave_backgrounder-0.1.0 | lib/backgrounder/workers/store_asset.rb |