Skip to content

Commit

Permalink
Don't try to add things that don't make sense.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Rarick committed Feb 28, 2008
1 parent e273f65 commit dcc86d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/beanstalk-client/connection.rb
Expand Up @@ -18,6 +18,7 @@
require 'socket'
require 'fcntl'
require 'yaml'
require 'set'
require 'beanstalk-client/bag'
require 'beanstalk-client/errors'
require 'beanstalk-client/job'
Expand Down Expand Up @@ -365,7 +366,12 @@ def make_hash(pairs)
end

def sum_hashes(hs)
hs.inject({}){|a,b| a.merge(b) {|k,o,n| o + n}}
hs.inject({}){|a,b| a.merge(b) {|k,o,n| combine_stats(k, o, n)}}
end

DONT_ADD = Set['name', 'version', 'pid']
def combine_stats(k, a, b)
DONT_ADD.include?(k) ? Set[a] + Set[b] : a + b
end
end
end

0 comments on commit dcc86d6

Please sign in to comment.