serializable_hash should just call include!

This commit is contained in:
Yehuda Katz 2012-01-11 15:48:16 -07:00
parent 5a8682b4e6
commit 020b2a19df

View File

@ -350,24 +350,25 @@ module ActiveModel
# Returns a hash representation of the serializable # Returns a hash representation of the serializable
# object without the root. # object without the root.
def serializable_hash def serializable_hash
if _embed == :ids node = attributes
merge_associations(@options[:hash], plural_associations) if _root_embed
attributes.merge(association_ids) if _embed
elsif _embed == :objects _associations.each do |attr, klass|
attributes.merge(associations) include! attr, :node => node
else end
attributes
end end
node
end end
def include!(name, options={}) def include!(name, options={})
embed = options[:embed] embed = options[:embed] || _embed
root_embed = options[:include] root_embed = options[:include] || _root_embed
hash = options[:hash] hash = options[:hash] || @options[:hash]
node = options[:node] node = options[:node]
value = options[:value] value = options[:value]
serializer = options[:serializer] serializer = options[:serializer]
scope = options[:scope] scope = options[:scope] || self.scope
association_class = _associations[name] association_class = _associations[name]
association = association_class.new(options) if association_class association = association_class.new(options) if association_class