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.
176 177 178 179 |
# File 'lib/resque_cleaner.rb', line 176 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.
168 169 170 171 |
# File 'lib/resque_cleaner.rb', line 168 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.
191 192 193 |
# File 'lib/resque_cleaner.rb', line 191 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.
182 183 184 185 186 187 188 |
# File 'lib/resque_cleaner.rb', line 182 def klass?(klass_or_name) if self["payload"] && self["payload"]["class"] self["payload"]["class"] == klass_or_name.to_s else klass_or_name=="UNKNOWN" end end |
#queue?(queue) ⇒ Boolean
Returns true if the queue of the job matches. Otherwise returns false.
196 197 198 |
# File 'lib/resque_cleaner.rb', line 196 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.
160 161 162 |
# File 'lib/resque_cleaner.rb', line 160 def retried? !self['retried_at'].nil? end |