mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
* Move all associations related code from Serializer class to Associations module * Introduce Reflection class hierarchy * Introduce Association class * Rid off Serializer#each_association * Introduce Serializer#associations enumerator
22 lines
509 B
Ruby
22 lines
509 B
Ruby
module ActiveModel
|
|
class Serializer
|
|
# This class hold all information about serializer's association.
|
|
#
|
|
# @param [Symbol] name
|
|
# @param [ActiveModel::Serializer] serializer
|
|
# @param [Hash{Symbol => Object}] options
|
|
#
|
|
# @example
|
|
# Association.new(:comments, CommentSummarySerializer, embed: :ids)
|
|
#
|
|
Association = Struct.new(:name, :serializer, :options) do
|
|
|
|
# @return [Symbol]
|
|
#
|
|
def key
|
|
options.fetch(:key, name)
|
|
end
|
|
end
|
|
end
|
|
end
|