Add default_embed_options

This commit is contained in:
Santiago Pastorino 2013-05-14 17:05:41 -07:00
parent e273a2fb37
commit 0b9f69529f

View File

@ -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