Skip to content

Instantly share code, notes, and snippets.

@paul
Created December 9, 2008 20:08
Show Gist options
  • Save paul/34062 to your computer and use it in GitHub Desktop.
Save paul/34062 to your computer and use it in GitHub Desktop.
// core.ssbe.localhost/clients/legacy_client
{
"_type": "Client",
"href": "http://core.ssbe.localhost/clients/legacy_client",
"id": "cecbab41-59cb-46fc-89e6-7d49ec60ccbe",
"name": "legacy_client",
"parent_href": "http://core.ssbe.localhost/clients/API",
"hosts_href": "http://core.ssbe.localhost/clients/legacy_client/hosts"
}
// core.ssbe.localhost/clients/legacy_client/hosts
{
"href" : "http://core.ssbe.localhost/clients/legacy_client/hosts",
"item_count": 1,
"items" : [
{
"_type" : "Host",
"id" : "a5ef5493-4780-4874-bd2f-39048bfe11e6",
"href" : "http://core.ssbe.localhost/hosts/1",
"name" : "legacy_hostname",
"client_href" : "http://core.ssbe.localhost/clients/legacy_client"
}
]
}
class Client
include DataMapper::Resource
# ...
property :hosts_href, String
# ...
has n, :hosts
end
class Host
include DataMapper::Resource
# ...
# property :client_href
# ...
belongs_to :client
end
client = Client.get('http://core.ssbe.localhost/clients/legacy_client')
client.hosts #=> [<#Host ...>, ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment