Skip to content

Commit

Permalink
Ruby 1.8.7 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Staubo committed May 18, 2011
1 parent e6369c4 commit 5b24a72
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/multidb/balancer.rb
Expand Up @@ -38,7 +38,8 @@ def initialize(configuration)
def get(name, &block)
candidates = @candidates[name] || []
raise ArgumentError, "No such database connection '#{name}'" if candidates.blank?
candidate = candidates.sample
candidate = candidates.respond_to?(:sample) ?
candidates.sample : candidates[rand(candidates.length)]
block_given? ? yield(candidate) : candidate
end

Expand Down

0 comments on commit 5b24a72

Please sign in to comment.