Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Rarick committed Apr 10, 2008
1 parent 39dfc00 commit a4b49da
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/beanstalk-client/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,10 @@ def yput(obj, pri=65536, delay=0, ttr=120)

def peek()
interact("peek\r\n", :job)
rescue NotFoundError
nil
end

def peek_job(id)
interact("peek #{id}\r\n", :job)
rescue NotFoundError
nil
end

def reserve()
Expand Down Expand Up @@ -150,7 +146,7 @@ def interact(cmd, rfmt)
raise WaitingForJobError if @waiting
@socket.write(cmd)
return read_yaml('OK') if rfmt == :yaml
return Job.new(@jptr, *read_job('FOUND')) if rfmt == :job
return found_job if rfmt == :job
check_resp(*rfmt)
end

Expand All @@ -169,6 +165,12 @@ def check_resp(*words)
vals
end

def found_job()
Job.new(@jptr, *read_job('FOUND'))
rescue NotFoundError
nil
end

def read_job(word)
id, bytes = check_resp(word).map{|s| s.to_i}
body = read_bytes(bytes)
Expand Down

0 comments on commit a4b49da

Please sign in to comment.