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