nesquena/rabl — pull request #183 by blakink (2012-03-09 08:36:50+00:00)
Title: Add "sibling" method to collection (issue #174)

Hi,

Let's take an example.
I need to get the following (JSON) hash to paginate my data.

{ total: 250,
page: 3,
total_pages: 25
data: [
{ id: 1, name: "Foo", ...},
{ id: 2, name: "Bar", ...}
]
}

Server-side. I use kaminari and I can now make that :

collection @items => :data

sibling :total_count => :total, :num_pages => :total_pages, :current_page => :page
attributes :id, :name

"Siblings" are methods to which the collection responds.

I guess my pull request is a first approach, and