Presently HyperResource will fail trying to load an embedded resource object that has no "_links" property, or a "_links" property but no "self" link, with an error message like
NoMethodError: undefined method `[]' for nil:NilClass
/.../lib/hyper_resource/adapter/hal_json.rb:50:in `block in apply_objects'
/.../lib/hyper_resource/adapter/hal_json.rb:45:in `each'
/.../lib/hyper_resource/adapter/hal_json.rb:45:in `apply_objects'
/.../lib/hyper_resource/adapter/hal_json.rb:30:in `apply'
...
Each Resource Object SHOULD [not MUST] contain a 'self' link...
This makes sense, as a resource corresponding to a weak or associative entity in a data model may have no identity of its own and thus no "self" link or any meaningful links at all. HyperResource should be able to work with resources of this type.
I've fixed this (I believe) locally and will submit a pull request soon.
Presently HyperResource will fail trying to load an embedded resource object that has no "_links" property, or a "_links" property but no "self" link, with an error message like
But according to the HAL spec,
and,
This makes sense, as a resource corresponding to a weak or associative entity in a data model may have no identity of its own and thus no "self" link or any meaningful links at all. HyperResource should be able to work with resources of this type.
I've fixed this (I believe) locally and will submit a pull request soon.