Module: Resque::Plugins::ResqueCleaner::FailedJobEx
- Defined in:
- lib/resque_cleaner.rb
Overview
Exntends job(Hash instance) with some helper methods.
Instance Method Summary collapse
-
#after?(time) ⇒ Boolean
Returns true if the job processed(failed) after the given time.
-
#before?(time) ⇒ Boolean
Returns true if the job processed(failed) before the given time.
-
#exception?(exception) ⇒ Boolean
Returns true if the exception raised by the failed job matches.
-
#klass?(klass_or_name) ⇒ Boolean
Returns true if the class of the job matches.
-
#queue?(queue) ⇒ Boolean
Returns true if the queue of the job matches.
-
#retried? ⇒ Boolean
(also: #requeued?)
Returns true if the job has been already retried.
Instance Method Details
#after?(time) ⇒ Boolean
Returns true if the job processed(failed) after the given time. Otherwise returns false. You can pass Time object or String.
167 168 169 170 |
# File 'lib/resque_cleaner.rb', line 167 def after?(time) time = Time.parse(time) if time.is_a?(String) Time.parse(self['failed_at']) >= time end |
#before?(time) ⇒ Boolean
Returns true if the job processed(failed) before the given time. Otherwise returns false. You can pass Time object or String.
159 160 161 162 |
# File 'lib/resque_cleaner.rb', line 159 def before?(time) time = Time.parse(time) if time.is_a?(String) Time.parse(self['failed_at']) < time end |
#exception?(exception) ⇒ Boolean
Returns true if the exception raised by the failed job matches. Otherwise returns false.
178 179 180 |
# File 'lib/resque_cleaner.rb', line 178 def exception?(exception) self["exception"] == exception.to_s end |
#klass?(klass_or_name) ⇒ Boolean
Returns true if the class of the job matches. Otherwise returns false.
173 174 175 |
# File 'lib/resque_cleaner.rb', line 173 def klass?(klass_or_name) self["payload"]["class"] == klass_or_name.to_s end |
#queue?(queue) ⇒ Boolean
Returns true if the queue of the job matches. Otherwise returns false.
183 184 185 |
# File 'lib/resque_cleaner.rb', line 183 def queue?(queue) self["queue"] == queue.to_s end |
#retried? ⇒ Boolean Also known as: requeued?
Returns true if the job has been already retried. Otherwise returns false.
151 152 153 |
# File 'lib/resque_cleaner.rb', line 151 def retried? !self['retried_at'].nil? end |