lib/resque_cleaner.rb in resque-cleaner-0.2.6 vs lib/resque_cleaner.rb in resque-cleaner-0.2.7

- old
+ new

@@ -51,11 +51,11 @@ # Stats by class. def stats_by_class(&block) jobs, stats = select(&block), {} jobs.each do |job| - klass = job["payload"]["class"] + klass = job["payload"] && job["payload"]["class"] ? job["payload"]["class"] : "UNKNOWN" stats[klass] ||= 0 stats[klass] += 1 end print_stats(stats) if print? @@ -169,11 +169,15 @@ Time.parse(self['failed_at']) >= time end # Returns true if the class of the job matches. Otherwise returns false. def klass?(klass_or_name) - self["payload"]["class"] == klass_or_name.to_s + if self["payload"] && self["payload"]["class"] + self["payload"]["class"] == klass_or_name.to_s + else + klass_or_name=="UNKNOWN" + end end # Returns true if the exception raised by the failed job matches. Otherwise returns false. def exception?(exception) self["exception"] == exception.to_s @@ -209,10 +213,10 @@ else on? ? @maximum : @cleaner.failure.count end end - # Returns jobs. If numbers of jobs is more than maixum, it returns only + # Returns jobs. If numbers of jobs is more than maximum, it returns only # the maximum. def jobs if @locked @jobs else