module CarrierWave::Workers::Base
Attributes
column[RW]
id[RW]
klass[RW]
record[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/backgrounder/workers/base.rb, line 8 def initialize(*args) super(*args) unless self.class.superclass == Object set_args(*args) if args.present? end
Public Instance Methods
perform(*args)
click to toggle source
# File lib/backgrounder/workers/base.rb, line 13 def perform(*args) set_args(*args) if args.present? self.record = constantized_resource.find id rescue *not_found_errors end
Private Instance Methods
constantized_resource()
click to toggle source
# File lib/backgrounder/workers/base.rb, line 32 def constantized_resource klass.is_a?(String) ? klass.constantize : klass end
not_found_errors()
click to toggle source
# File lib/backgrounder/workers/base.rb, line 21 def not_found_errors [].tap do |errors| errors << ::ActiveRecord::RecordNotFound if defined?(::ActiveRecord) errors << ::Mongoid::Errors::DocumentNotFound if defined?(::Mongoid) end end
set_args(klass, id, column)
click to toggle source
# File lib/backgrounder/workers/base.rb, line 28 def set_args(klass, id, column) self.klass, self.id, self.column = klass, id, column end
when_not_ready()
click to toggle source
# File lib/backgrounder/workers/base.rb, line 36 def when_not_ready end