lib/parallel_minion/minion.rb in parallel_minion-0.2.1 vs lib/parallel_minion/minion.rb in parallel_minion-0.3.0
- old
+ new
@@ -111,10 +111,11 @@
options = self.class.extract_options!(args).dup
@timeout = (options.delete(:timeout) || Minion::INFINITE).to_f
@description = (options.delete(:description) || 'Minion').to_s
+ @metric = options.delete(:metric)
@log_exception = options.delete(:log_exception)
@enabled = options.delete(:enabled)
@enabled = self.class.enabled? if @enabled.nil?
# Warn about any unknown options.
@@ -126,11 +127,11 @@
# Run the supplied block of code in the current thread for testing or
# debugging purposes
if @enabled == false
begin
logger.info("Started in the current thread: #{@description}")
- logger.benchmark_info("Completed in the current thread: #{@description}", log_exception: @log_exception) do
+ logger.benchmark_info("Completed in the current thread: #{@description}", log_exception: @log_exception, metric: @metric) do
@result = instance_exec(*args, &block)
end
rescue Exception => exc
@exception = exc
end
@@ -219,18 +220,20 @@
@enabled
end
# Returns the current scopes for each of the models for which scopes will be
# copied to the Minions
- if ActiveRecord::VERSION::MAJOR >= 4
- def self.current_scopes
- @@scoped_classes.collect {|klass| klass.all}
+ if defined?(ActiveRecord)
+ if ActiveRecord::VERSION::MAJOR >= 4
+ def self.current_scopes
+ @@scoped_classes.collect {|klass| klass.all}
+ end
+ else
+ def self.current_scopes
+ @@scoped_classes.collect {|klass| klass.scoped}
+ end
end
- else
- def self.current_scopes
- @@scoped_classes.collect {|klass| klass.scoped}
- end
end
protected
@@enabled = true
@@ -240,6 +243,6 @@
def self.extract_options!(args)
args.last.is_a?(Hash) ? args.pop : {}
end
end
-end
\ No newline at end of file
+end