mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Propagate serialization_options across associations
This commit is contained in:
parent
f1c3268a54
commit
ea6dc424ee
@ -161,7 +161,7 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def associations
|
def associations(options={})
|
||||||
associations = self.class._associations
|
associations = self.class._associations
|
||||||
included_associations = filter(associations.keys)
|
included_associations = filter(associations.keys)
|
||||||
associations.each_with_object({}) do |(name, association), hash|
|
associations.each_with_object({}) do |(name, association), hash|
|
||||||
@ -178,7 +178,7 @@ end
|
|||||||
if association.embed_namespace?
|
if association.embed_namespace?
|
||||||
hash = hash[association.embed_namespace] ||= {}
|
hash = hash[association.embed_namespace] ||= {}
|
||||||
end
|
end
|
||||||
hash[association.embedded_key] = serialize association
|
hash[association.embedded_key] = serialize association, options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -236,8 +236,8 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize(association)
|
def serialize(association,options={})
|
||||||
build_serializer(association).serializable_object
|
build_serializer(association).serializable_object(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialize_ids(association)
|
def serialize_ids(association)
|
||||||
@ -282,7 +282,7 @@ end
|
|||||||
self.serialization_options = options
|
self.serialization_options = options
|
||||||
return @wrap_in_array ? [] : nil if @object.nil?
|
return @wrap_in_array ? [] : nil if @object.nil?
|
||||||
hash = attributes
|
hash = attributes
|
||||||
hash.merge! associations
|
hash.merge! associations(options)
|
||||||
hash = convert_keys(hash) if key_format.present?
|
hash = convert_keys(hash) if key_format.present?
|
||||||
hash = { :type => type_name(@object), type_name(@object) => hash } if @polymorphic
|
hash = { :type => type_name(@object), type_name(@object) => hash } if @polymorphic
|
||||||
@wrap_in_array ? [hash] : hash
|
@wrap_in_array ? [hash] : hash
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user