-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Move serialization logic into Serializer and CollectionSerializer #1766
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
@@ -98,6 +98,16 @@ def self.get_serializer_for(klass) | |||
end | |||
end | |||
|
|||
def self.include_directive_from_options(options) |
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.
missing @api private
. These methods are being held here for now, but may move around, be renamed, or disappear
13b7b9d
to
bbcb7bc
Compare
@bf4 are you wanting to add a changelog entry? anywho, the change looks good. I'd forgotten we had some serializer stuff in an adapter. |
adapter.serializable_hash(adapter_opts) | ||
adapter_opts = { include: '*' }.merge!(adapter_opts) | ||
adapter_instance = ActiveModelSerializers::Adapter::Attributes.new(self, adapter_opts) | ||
serialize(adapter_opts, {}, adapter_instance) |
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.
It really irritates me that this requires an adapter_instance (else I get a stack overflow).
The used adapter_instance interface is
- cached_name : used in making cache key
- class : used by fragment caching in fragment serializers
- fragment_cache : used by fragment caching
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.
actually, all of those can be class methods, now that I think about it.
adapter_opts = { include: '*', adapter: :attributes }.merge!(adapter_opts) | ||
adapter = ActiveModelSerializers::Adapter.create(self, adapter_opts) | ||
adapter.serializable_hash(adapter_opts) | ||
adapter_opts = { include: '*' }.merge!(adapter_opts) |
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 use the JSONAPI default include directive, I think
@@ -98,6 +98,22 @@ def self.get_serializer_for(klass) | |||
end | |||
end | |||
|
|||
# @api private | |||
def self.include_directive_from_options(options) |
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 go in AMS or some other serialization-related class
Merging just to keep momentum going |
Extracted from #1684
Benchmark on my mbp just now looks good