rcarver/orel — pull request #3 by rcarver (2014-10-08 04:28:11+00:00)
Title: Query and return the result in batches

This implements the ability to chunk the results into batches.

When the `:batch_size` option is passed to `query`, the result is an `Enumerator` instead of an `Array`.

```
users = User.query(:batch_size => 1000) do |q, u|
q.where u[:first_name].eq("Joe")
end
users.each do |user|
# do stuff with user
end
```

Pass `:group => true` to yield each batch as an array, instead of enumerating each object.

```
# with grouping
users = User.query(:batch_size => 1000, :group => true) do |q, u|
q.where u[:first_name].eq("Joe")
end
users.each do |batch|
batch.each do |user
# do stuff with user
end
end
```