0
0
Fork 0

Remove unused ActivityPub @context values depending on response (#10378)

Fix #8078
This commit is contained in:
Eugen Rochko 2019-03-27 15:55:23 +01:00 committed by GitHub
parent a91acf79b5
commit 11fe293e1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 234 additions and 60 deletions

View file

@ -3,3 +3,22 @@ ActiveModelSerializers.config.tap do |config|
end
ActiveSupport::Notifications.unsubscribe(ActiveModelSerializers::Logging::RENDER_EVENT)
class ActiveModel::Serializer::Reflection
# We monkey-patch this method so that when we include associations in a serializer,
# the nested serializers can send information about used contexts upwards back to
# the root. We do this via instance_options because the nesting can be dynamic.
def build_association(parent_serializer, parent_serializer_options, include_slice = {})
serializer = options[:serializer]
parent_serializer_options.merge!(named_contexts: serializer._named_contexts, context_extensions: serializer._context_extensions) if serializer.respond_to?(:_named_contexts)
association_options = {
parent_serializer: parent_serializer,
parent_serializer_options: parent_serializer_options,
include_slice: include_slice,
}
ActiveModel::Serializer::Association.new(self, association_options)
end
end