Created
May 14, 2013 14:29
-
-
Save albertoleal/5576387 to your computer and use it in GitHub Desktop.
Roar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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