mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
Associations doesn't depend on the source serializer anymore :)
This commit is contained in:
parent
c1e710aae1
commit
c04d452823
@ -218,7 +218,7 @@ module ActiveModel
|
|||||||
|
|
||||||
associations = {}
|
associations = {}
|
||||||
_associations.each do |attr, (association_class, options)|
|
_associations.each do |attr, (association_class, options)|
|
||||||
association = association_class.new(attr, self, options)
|
association = association_class.new(attr, options)
|
||||||
|
|
||||||
if model_association = klass.reflect_on_association(association.name)
|
if model_association = klass.reflect_on_association(association.name)
|
||||||
# Real association.
|
# Real association.
|
||||||
@ -381,7 +381,7 @@ module ActiveModel
|
|||||||
options[:embed] = _embed unless options.key?(:embed)
|
options[:embed] = _embed unless options.key?(:embed)
|
||||||
options[:include] = _root_embed unless options.key?(:include)
|
options[:include] = _root_embed unless options.key?(:include)
|
||||||
options[:serializer_options] = self.options
|
options[:serializer_options] = self.options
|
||||||
association = association_class.new(name, self, options)
|
association = association_class.new(name, options)
|
||||||
|
|
||||||
if association.embed_ids?
|
if association.embed_ids?
|
||||||
node[association.key] =
|
node[association.key] =
|
||||||
|
|||||||
@ -2,9 +2,8 @@ module ActiveModel
|
|||||||
class Serializer
|
class Serializer
|
||||||
module Associations #:nodoc:
|
module Associations #:nodoc:
|
||||||
class Config #:nodoc:
|
class Config #:nodoc:
|
||||||
def initialize(name, source, options={})
|
def initialize(name, options={})
|
||||||
@name = name
|
@name = name
|
||||||
@source = source
|
|
||||||
@options = options
|
@options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -13,10 +12,6 @@ module ActiveModel
|
|||||||
serializer.is_a?(String) ? serializer.constantize : serializer
|
serializer.is_a?(String) ? serializer.constantize : serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_serializer
|
|
||||||
@source
|
|
||||||
end
|
|
||||||
|
|
||||||
def key
|
def key
|
||||||
options[:key] || @name
|
options[:key] || @name
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user