blongden/hal — pull request #23 by davedevelopment (2013-06-13 21:53:46+00:00)
Title: Allowing setting a single object as an embedded resource

Unless I'm mistaken, there's no way to render the following?

``` javascript

{
"_links": {
.. *snip* ..
},
"_embedded": {
"manufacturer": {
"_links": {
"self": { "href": "/manufacturers/328764" },
"homepage": { "href": "http://hoverdonkey.com" }
},
"name": "Manufacturer Inc."
},

.. *snip* ..
}
```

I'm not entirely sold on the API in this PR, as the `setResource` method is only really valid for those wanting to render json. I could spruce it up a bit to accept either a Hal or an array of Hals, in which case it would be relevant to both, i.e. you can add a collection in one call rather than several.

Another option would be to allow some sort of notation on the addResource rel string, but I'm not really keen on that either.

NB: I've not done anything with regards to deserialising yet, I'll do that when/if we agree on API for what I'm trying to achieve.