lib/picky/query/allocations.rb in picky-3.6.15 vs lib/picky/query/allocations.rb in picky-3.6.16

- old
+ new

@@ -9,10 +9,11 @@ delegate :each, :empty?, :first, :inject, :size, + :map, :to => :@allocations def initialize allocations = [] @allocations = allocations end @@ -78,21 +79,24 @@ offset = offset - allocation.count unless offset.zero? else amount = amount - ids.size # we need less results from the following allocation offset = 0 # we have already passed the offset end - if terminate_early - break if terminate_early <= 0 && amount <= 0 + if terminate_early && amount <= 0 + break if terminate_early <= 0 terminate_early -= 1 end end end # The total is simply the sum of the counts of all allocations. # def total - @total ||= inject(0) do |total, allocation| - total + (allocation.count || break) + @total ||= calculate_total + end + def calculate_total + inject(0) do |total, allocation| + total + (allocation.count or return total) end end def uniq @allocations.uniq! \ No newline at end of file