mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06: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
|
||||
# object without the root.
|
||||
def serializable_hash
|
||||
if _embed == :ids
|
||||
merge_associations(@options[:hash], plural_associations) if _root_embed
|
||||
attributes.merge(association_ids)
|
||||
elsif _embed == :objects
|
||||
attributes.merge(associations)
|
||||
else
|
||||
attributes
|
||||
node = attributes
|
||||
|
||||
if _embed
|
||||
_associations.each do |attr, klass|
|
||||
include! attr, :node => node
|
||||
end
|
||||
end
|
||||
|
||||
node
|
||||
end
|
||||
|
||||
def include!(name, options={})
|
||||
embed = options[:embed]
|
||||
root_embed = options[:include]
|
||||
hash = options[:hash]
|
||||
embed = options[:embed] || _embed
|
||||
root_embed = options[:include] || _root_embed
|
||||
hash = options[:hash] || @options[:hash]
|
||||
node = options[:node]
|
||||
value = options[:value]
|
||||
serializer = options[:serializer]
|
||||
scope = options[:scope]
|
||||
scope = options[:scope] || self.scope
|
||||
|
||||
association_class = _associations[name]
|
||||
association = association_class.new(options) if association_class
|
||||
|
||||
Loading…
Reference in New Issue
Block a user