Skip to content
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

put back 0.9.x serializer instance #to_hash or #serializable_hash #1321

Closed
maliqq opened this issue Nov 7, 2015 · 5 comments
Closed

put back 0.9.x serializer instance #to_hash or #serializable_hash #1321

maliqq opened this issue Nov 7, 2015 · 5 comments

Comments

@maliqq
Copy link

maliqq commented Nov 7, 2015

instead of

ActiveModel::SerializableResource.new(@message, serializer: MySerializer)

to this

MySerializer.new(@message).to_hash # or #serializable_hash
@bf4
Copy link
Member

bf4 commented Nov 9, 2015

Would you mind clarifying which ams version you're targeting? Also, what's your use case? Call serializer.attributes if you want the raw attributes.

@nikolai-b
Copy link

This is an issue on master. I'm using rocket pants which uses that method. It isn't a big issue to change but MySerializer.new(@message).serializable_hash does feel a bit nicer to use.

@bf4
Copy link
Member

bf4 commented Dec 16, 2015

This issue comes up a lot in the 0.10 series. Someone (me? you?) should really add this to common issues and resolutions section in contributing

So, tl;dr the serializer has a different interface because it is different. I'm not sure what kind of output you're expecting, but you could monkey patch the serializer with a call to the serializable resource and the attributes adapter.

The serializer in the 0.10 series does have an attributes and associations method, but I'm not sure that's what you want.

I'll add a comment in that PR. Thanks for the link.

@bf4
Copy link
Member

bf4 commented Dec 16, 2015

I'm going to close this, but feel free to continue asking questions, and re-open if you think there's a solution that fits in this lib.

@bf4
Copy link
Member

bf4 commented Jun 4, 2016

btw, this is now done in 0.10.0 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants