-
Notifications
You must be signed in to change notification settings - Fork 90
simple namespace implementation added #79
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
Nice! Quick questions: |
Explicit discovery only maps a model to a single serializer. My use case is an application with multiple API backends. So, yes, I'm solving a similar problem: Can you explain the recursive include case to me? |
Sounds right! For the recursive case just make sure that |
In which order should the serializer lookup work, we have:
I think |
Specs, Readme and 'lookup preference' updated. |
Added fix to pass the namespace to the include serialization. Not sure how to test this correctly. |
has_one :author | ||
has_many :long_comments | ||
|
||
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.
Drop these meta attributes, they're not doing anything as far as I can tell.
Slowly getting back to this, this looks good to me! One comment above about some cleanup and then good to go. |
Updated the PR according to your feedback. |
Released in gem v0.14.0, thanks for your contribution! |
Awesome! Thank you for merging and releasing! 👍 |
Only thing i've added is the
options
parameter tofind_serializer_class_name
method so that it can use theoptions[:namespace]
parameter to prefix the class lookup:"#{options[:namespace]}::#{object.class.name}Serializer"
. The sub serializers are namespaced as well.Usage:
JSONAPI::Serializer.serialize(object, namespace: ::MyApi)
or
JSONAPI::Serializer.serialize(object, namespace: '::MyApi')
No test or documentation at the moment, but if this PR is acceptable I can make them.