mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Note that we dup the entire reflection instance
This commit is contained in:
parent
c7e847fc72
commit
b358271ef5
@ -347,7 +347,7 @@ module ActiveModel
|
||||
return Enumerator.new {} unless object
|
||||
|
||||
Enumerator.new do |y|
|
||||
(@reflections ||= self.class._reflections.deep_dup).each do |key, reflection|
|
||||
(self.instance_reflections ||= self.class._reflections.deep_dup).each do |key, reflection|
|
||||
next if reflection.excluded?(self)
|
||||
next unless include_directive.key?(key)
|
||||
|
||||
@ -411,6 +411,6 @@ module ActiveModel
|
||||
|
||||
protected
|
||||
|
||||
attr_accessor :instance_options, :reflections
|
||||
attr_accessor :instance_options, :instance_reflections
|
||||
end
|
||||
end
|
||||
|
||||
@ -151,6 +151,9 @@ module ActiveModel
|
||||
# @yield [ActiveModel::Serializer]
|
||||
# @return [:nil, associated resource or resource collection]
|
||||
def value(serializer, include_slice)
|
||||
# NOTE(BF): This method isn't thread-safe because the _reflections class attribute is not thread-safe
|
||||
# Therefore, when we build associations from reflections, we dup the entire reflection instance.
|
||||
# Better solutions much appreciated!
|
||||
@object = serializer.object
|
||||
@scope = serializer.scope
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user