trailblazer / roar-rails

Use Roar's representers in Rails.
http://roar.apotomo.de
MIT License
235 stars 65 forks source link

Collection representer #92

Open summera opened 9 years ago

summera commented 9 years ago

@apotonick After running into https://github.com/apotonick/roar-rails/issues/77, I created a CollectionRepresenter to use in my own projects with Decorators. It makes creating collections really simple.

I updated the README with an explanation, but in short:

class BandsRepresenter < Roar::Decorator
  include Roar::Representer::JSON
  include Roar::Representer::Feature::Hypermedia
  include Roar::Rails::CollectionRepresenter
end

This creates a Bands Collection Representer using the BandRepresenter to serialize each individual resource within the collection.

Let me know what you think!

ianks commented 9 years ago

:+1: