Skip to content
Browse files

Merge branch 'master' of https://github.com/lardawge/carrierwave_back…

…grounder as asked in #53
  • Loading branch information...
2 parents 8faca8c + 333365c commit 4d8153766ff5893f0b32a92d381fcf1b35d7fa7f @vtabary committed
Showing with 9 additions and 5 deletions.
  1. +2 −2 lib/backgrounder/orm/activerecord.rb
  2. +4 −0 lib/backgrounder/orm/base.rb
  3. +3 −3 lib/backgrounder/orm/mongoid.rb
View
4 lib/backgrounder/orm/activerecord.rb
@@ -13,7 +13,7 @@ def process_in_background(column, worker=::CarrierWave::Workers::ProcessAsset)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def trigger_#{column}_background_processing?
- process_#{column}_upload != true && #{column}_changed?
+ super && (#{column}_changed? || remote_#{column}_url.present?)
end
RUBY
end
@@ -23,7 +23,7 @@ def store_in_background(column, worker=::CarrierWave::Workers::StoreAsset)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def trigger_#{column}_background_storage?
- process_#{column}_upload != true && #{column}_changed?
+ super && (#{column}_changed? || remote_#{column}_url.present?)
end
RUBY
end
View
4 lib/backgrounder/orm/base.rb
@@ -60,6 +60,8 @@ def enqueue_#{column}_background_job
::Qu.enqueue #{worker}, self.class.name, id.to_s, #{column}.mounted_as
elsif defined? ::Sidekiq
::Sidekiq::Client.enqueue #{worker}, self.class.name, id.to_s, #{column}.mounted_as
+ elsif defined? ::QC
+ ::QC.enqueue "#{worker}.perform", self.class.name, id.to_s, #{column}.mounted_as.to_s
end
end
@@ -118,6 +120,8 @@ def enqueue_#{column}_background_job
::Qu.enqueue #{worker}, self.class.name, id.to_s, #{column}.mounted_as
elsif defined? ::Sidekiq
::Sidekiq::Client.enqueue #{worker}, self.class.name, id.to_s, #{column}.mounted_as
+ elsif defined? ::QC
+ ::QC.enqueue "#{worker}.perform", self.class.name, id.to_s, #{column}.mounted_as.to_s
end
end
View
6 lib/backgrounder/orm/mongoid.rb
@@ -10,7 +10,7 @@ def process_in_background(column, worker=::CarrierWave::Workers::ProcessAsset)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def trigger_#{column}_background_processing?
- process_#{column}_upload != true && #{column}_changed?
+ super && (#{column}_changed? || remote_#{column}_url.present?)
end
RUBY
end
@@ -20,7 +20,7 @@ def store_in_background(column, worker=::CarrierWave::Workers::StoreAsset)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def trigger_#{column}_background_storage?
- process_#{column}_upload != true && #{column}_changed?
+ super && (#{column}_changed? || remote_#{column}_url.present?)
end
RUBY
end
@@ -30,4 +30,4 @@ def trigger_#{column}_background_storage?
end # Backgrounder
end # CarrierWave
-Mongoid::Document::ClassMethods.send(:include, ::CarrierWave::Backgrounder::ORM::Mongoid)
+Mongoid::Document::ClassMethods.send(:include, ::CarrierWave::Backgrounder::ORM::Mongoid)

0 comments on commit 4d81537

Please sign in to comment.
Something went wrong with that request. Please try again.