-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Move meta/meta_key handling inside adapter.
#1233
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
Conversation
22c0bd0 to
56b5fb1
Compare
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.
Those readers simply do not exist anymore.
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.
👍
56b5fb1 to
c4a137a
Compare
test/serializers/meta_test.rb
Outdated
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.
formatting?
.as_json
feels so lonely
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.
How would you rather have it?
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.
ActiveModel::SerializableResource.new(
[@blog],
adapter: :attributes,
meta: { total: 10 }
).as_jsonThere 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.
I could live with that. Will update.
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.
Done.
c4a137a to
fab6f3f
Compare
|
can you rebase? |
|
thanks! |
|
Wait, I'll rebase. |
49f0c88 to
503bfe9
Compare
|
Rebased. |
|
woo! |
Move `meta`/`meta_key` handling inside adapter.
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.
👍
|
Did this break existing examples for supplying meta from with a CollectionSerializer? It doesn't seem like that's possible now. Should those be updated to show to override the adapter for this behavior? |
|
@trek Not sure I understand what you meant. Could you sketch some code to show what you have in mind? |
|
The pagination example here doesn't work after moving It looks like we didn't also add the documentation for centrally overriding serialization to include meta. The JSON API Adapter, for example, will include links automatically but the only way we could figure out how to get extra keys into the top level object (in this case for pagination) was creating our own adapter and overriding There might be a better way, but we couldn't find an interface for it on master. It'd be good to document getting keys into the top level hash. |
|
@trek You are right. Note that, in master, you can always provide the |
The (toplevel)
metahandling is clearly an adapter concern.