mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Refactor Association into Field like everything else (#1897)
* Make assocations asserts easier to understand * Refactor Association into Field like everything else * Make assocation serializer/links/meta lazier * Push association deeper into relationship * Simplify association usage in relationships * Better naming of reflection parent serializer * Easier to read association method
This commit is contained in:
committed by
L. Preston Sego III
parent
7d2997b3ff
commit
20e394d512
@@ -155,15 +155,17 @@ module ActiveModelSerializers
|
||||
|
||||
serializable_resource_options = {} # adapter.instance_options
|
||||
|
||||
meta = test_options.delete(:meta)
|
||||
options = test_options.delete(:options)
|
||||
links = test_options.delete(:links)
|
||||
options = test_options.delete(:options) || {}
|
||||
options[:links] = test_options.delete(:links)
|
||||
options[:meta] = test_options.delete(:meta)
|
||||
association_serializer = @serializer
|
||||
if association_serializer && association_serializer.object
|
||||
association_name = association_serializer.json_key.to_sym
|
||||
association = ::ActiveModel::Serializer::Association.new(association_name, association_serializer, options, links, meta)
|
||||
options[:serializer] = association_serializer
|
||||
association = ::ActiveModel::Serializer::Association.new(association_name, options, nil)
|
||||
else
|
||||
association = ::ActiveModel::Serializer::Association.new(:association_name_not_used, association, options, links, meta)
|
||||
options[:serializer] = association
|
||||
association = ::ActiveModel::Serializer::Association.new(:association_name_not_used, options, nil)
|
||||
end
|
||||
|
||||
relationship = Relationship.new(parent_serializer, serializable_resource_options, association)
|
||||
|
||||
Reference in New Issue
Block a user