Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Correct example code #48

Merged
merged 1 commit into from

2 participants

@anthonylewis

Accessing a hash key that does not exist returns nil. nil.to_i is 0. So, the original version would set total to 0 when a length was not specified. That would skip the while loop and the job would complete immediately.

This correction will set total to 1000 when options['length'] is nil as intended.

@anthonylewis anthonylewis Accessing a hash key that does not exist returns nil. nil.to_i is 0. …
…So, the original version would set total to 0 when a length was not specified. That would skip the while loop and the job would complete immediately.


This correction will set total to 1000 when options['length'] is nil as intended.
56375c8
@quirkey quirkey merged commit 14ce1f7 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 28, 2011
  1. @anthonylewis

    Accessing a hash key that does not exist returns nil. nil.to_i is 0. …

    anthonylewis authored
    …So, the original version would set total to 0 when a length was not specified. That would skip the while loop and the job would complete immediately.
    
    
    This correction will set total to 1000 when options['length'] is nil as intended.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  examples/sleep_job.rb
View
2  examples/sleep_job.rb
@@ -5,7 +5,7 @@
class SleepJob < Resque::JobWithStatus
def perform
- total = options['length'].to_i || 1000
+ total = options.has_key?('length') ? options['length'].to_i : 1000
num = 0
while num < total
at(num, total, "At #{num} of #{total}")
Something went wrong with that request. Please try again.