Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
class ActiveRecord::Base def self.lazy_find(args = {}, &block) total = self.count(*args) count = 0 args[:limit] ||= 100 args[:offset] = count while items = self.find(:all, args) and not items.empty? items.each do |item| args[:offset] += 1 block.call item end puts "#{sprintf("%2.2f", 100 * count.to_f / total)}%: #{count}\n" end end end
This paste will be private.
From the Design Piracy series on my blog: