tylerhunt/brewery_db — pull request #30 by jnunemaker (2014-02-17 20:41:38+00:00)
Title: Expose response

This exposes response and allows for conversion between paginated and unpaginated collections. While the enumerable is nice when you want to deal with a lot of records, sometimes I just want the raw response, even for things like listing all beers or search results, so I get can paging information.

Also, it adds convenience methods collection and paginated_collection to both Collection and PaginatedCollection so you can convert between the two. For context, I'm using this stuff in combination with will paginate to do actual web paging for listing/searching:

```ruby
paginated_collection = client.search.beers(options)
response = paginated_collection.response
page = response.page_number
count = response.count

collection = paginated_collection.collection
beers = collection.map { |beer| load beer }

WillPaginate::Collection.create(page, per_page, count) do |pager|
pager.replace(beers)
end
```

These are all wrapped up in a ruby class, but that is the gist of why. If you aren't interested in exposing these or have a better way, let me know.