-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support arrays of links with JSON HAL #33
Comments
Oh I was hoping this is a pull request ;-) |
So, to have links we currently have the following mechanics. link :self do
product_url(self)
end
link :rel => :self, :title => "Myself" do
product_url(self)
end I'd love to have the following. link :self do
{:title => full_title, :href => ..}
end Here, you can return a hash where the block itself is executed in instance context, meaning you can access attributes of the represented object at runtime (like link :self, :array => true do
[ {:title => full_title, :href => ..},
..
]
end When |
Has the format link :self do
{:title => full_title, :href => ..}
end been implemented yet? It sort of works, but I get the links nested under an "self":{
"href":{
"title":"Awesome generated name",
"href":"/reports/20121025161822"
}
} I need to be able to access a method on the model to determine the proper title to display, and I can't do that by passing a hash to the link method itself. |
Since this years' conference season is over for me I finally have time to code! Expect all of the upper behaviour in less than a week :-) |
sorry to ping you again about this, but it's a sticking point in my API |
🌟 🌟 💃 👯 💃 🌟 🌟 |
JSON HAL spec (http://tools.ietf.org/html/draft-kelly-json-hal-03#section-4.1.1) says,
[_links] is an object whose property names are link relation types (as defined by [RFC5988]) and values are either a Link Object or an array of Link Objects.
Mike Kelly gives an example of what that looks like (https://groups.google.com/group/hal-discuss/msg/5afa41ab1740aee1):
Presently, if you try to use an array of links, the output is more like:
The text was updated successfully, but these errors were encountered: