mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Refactor relationships_for.
This commit is contained in:
parent
c593adbcb2
commit
a8a0566d29
@ -109,12 +109,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def relationships_for(serializer)
|
def relationships_for(serializer)
|
||||||
relationships = {}
|
serializer.associations.map { |association| [ association.key, { data: relationship_value_for(association.serializer, association.options) } ] }.to_h
|
||||||
serializer.associations.each do |association|
|
|
||||||
value = relationship_value_for(association.serializer, association.options)
|
|
||||||
relationships[association.key] = { data: value }
|
|
||||||
end
|
|
||||||
relationships
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def included_for(serializer)
|
def included_for(serializer)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user