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