mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Add default_embed_options
This commit is contained in:
parent
e273a2fb37
commit
0b9f69529f
@ -377,9 +377,8 @@ module ActiveModel
|
|||||||
Associations::HasOne
|
Associations::HasOne
|
||||||
end
|
end
|
||||||
|
|
||||||
|
options = default_embed_options.merge!(options)
|
||||||
options[:value] ||= send(name)
|
options[:value] ||= send(name)
|
||||||
options[:embed] = _embed unless options.key?(:embed)
|
|
||||||
options[:include] = _root_embed unless options.key?(:include)
|
|
||||||
association = association_class.new(name, options, self.options)
|
association = association_class.new(name, options, self.options)
|
||||||
|
|
||||||
if association.embed_ids?
|
if association.embed_ids?
|
||||||
@ -452,6 +451,15 @@ module ActiveModel
|
|||||||
event_name = INSTRUMENT[name]
|
event_name = INSTRUMENT[name]
|
||||||
ActiveSupport::Notifications.instrument(event_name, payload, &block)
|
ActiveSupport::Notifications.instrument(event_name, payload, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def default_embed_options
|
||||||
|
{
|
||||||
|
:embed => _embed,
|
||||||
|
:include => _root_embed
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# DefaultSerializer
|
# DefaultSerializer
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user