Skip to content

Instantly share code, notes, and snippets.

@albertoleal
Created May 14, 2013 14:29
Show Gist options
  • Save albertoleal/5576387 to your computer and use it in GitHub Desktop.
Save albertoleal/5576387 to your computer and use it in GitHub Desktop.
Roar
module ApiRepresenter
include Roar::Representer::JSON
property :name
end
module ApisRepresenter
include Representable::JSON::Collection
self.representation_wrap= :items
items extend: ApiRepresenter
property :foo
def foo
"bar"
end
end
class Api < OpenStruct; end;
f = Api.new(:name => "Foo")
b = Api.new(:name => "Bar")
[f, b].extend(ApisRepresenter).to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment