lib/backgrounder/orm/data_mapper.rb in carrierwave_backgrounder-0.2.1 vs lib/backgrounder/orm/data_mapper.rb in carrierwave_backgrounder-0.2.2
- old
+ new
@@ -4,24 +4,22 @@
module DataMapper
include CarrierWave::Backgrounder::ORM::Base
def process_in_background(column, worker=::CarrierWave::Workers::ProcessAsset)
- before :save, :"set_#{column}_processing"
- after :save, :"enqueue_#{column}_background_job"
+ super
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def set_#{column}_processing
@#{column}_changed = attribute_dirty?(:#{column})
self.#{column}_processing = true if respond_to?(:#{column}_processing)
end
RUBY
end
def store_in_background(column, worker=::CarrierWave::Workers::StoreAsset)
- before :save, :"set_#{column}_changed"
- after :save, :"enqueue_#{column}_background_job"
+ super
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def set_#{column}_changed
@#{column}_changed = attribute_dirty?(:#{column})
end
@@ -34,10 +32,14 @@
end
private
def _define_shared_backgrounder_methods(mod, column, worker)
+ before :save, :"set_#{column}_changed"
+ after :save, :"enqueue_#{column}_background_job"
+
super
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
attr_reader :#{column}_changed
def enqueue_#{column}_background_job
if enqueue_#{column}_background_job?