-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for resource-level meta. #1340
Conversation
@gaganawhad following your offer in
Do you think you could give a hand here? All help is welcome :) |
Thanks @kurko! @gaganawhad in case you'd like to give a hand, stuff is happening on my branch. |
77c14a2
to
ee8c0e0
Compare
Waiting for travis, but otherwise looks good to me. @bf4 @NullVoxPopuli, thoughts? |
@post, | ||
serializer: MetaHashPostSerializer, | ||
adapter: :json_api | ||
).serializable_hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, there's a test support helper serializable
but it wouldn't make things much shorter. Do you think we should test Ruby hashes made from as_json
instead of serializable_hash in the future?
Just thinking out loud: Given that Where meta is used:
I'm a little iffy with defining the meta on the serializer, but I'm not sure where it would otherwise go. JSONAPI-Resources puts the meta in the |
@bf4 The way I understand the spec, resource-level |
@@ -233,6 +248,14 @@ def links | |||
self.class._links | |||
end | |||
|
|||
def meta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we prefer _meta
even though there shouldn't be attribute method conflicts anymore?
@beauby would you mind adding the
|
@@ -50,6 +50,8 @@ def self.digest_caller_file(caller_line) | |||
serializer.class_attribute :_type, instance_reader: true | |||
serializer.class_attribute :_links # @api private : links definitions, @see Serializer#link | |||
self._links ||= {} | |||
class_attribute :_meta # @api private : meta definition, @see Serializer#meta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be serializaer.class_attribute :_meta
.
ee8c0e0
to
207c85f
Compare
Resource-level meta tests are expected to fail after last commit, since the handling of the option itself ( |
@beauby what does that mean? Expected to fail, which means this PR is WIP? |
@kurko I meant that those 2 failing tests were testing implementation-specific stuff that does not exist anymore. I'll update them (or get rid of them if they don't make sense at all anymore) tonight if I get a chance, or tomorrow. Thanks for the ping! |
- Add changelog entry - Remove superseded and incorrect tests - Fix array serialization test
Merged. Added followup issues and addressed more urgent ones |
Hey guys - question that I'm not sure from the jsonapi spec. Should the meta be rendered when you include a resource in a request? Let's say you have something like this:
Should the following request include the meta information for the user?
|
@rafael Since the Since you asked about the spec itself, you would probably get a more appropriate answer at discuss.jsonapi.org. 😉 |
Untested, but should work. Would love for somebody to provide a few tests, as I am rather busy myself at the moment.
Ref: #1339, #1235.