mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
serializable_hash should just call include!
This commit is contained in:
parent
5a8682b4e6
commit
020b2a19df
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user