mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Rename method to serializable_object
This commit is contained in:
parent
f14f931957
commit
0f4547eb77
@ -35,12 +35,12 @@ module ActiveModel
|
|||||||
serializer_class.new(item, @options)
|
serializer_class.new(item, @options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def serializable_array
|
def serializable_object
|
||||||
@object.map do |item|
|
@object.map do |item|
|
||||||
serializer_for(item).serializable_object
|
serializer_for(item).serializable_object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
alias_method :serializable_object, :serializable_array
|
alias_method :serializable_array, :serializable_object
|
||||||
|
|
||||||
def embedded_in_root_associations
|
def embedded_in_root_associations
|
||||||
@object.each_with_object({}) do |item, hash|
|
@object.each_with_object({}) do |item, hash|
|
||||||
|
|||||||
@ -169,12 +169,12 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def serializable_hash(options={})
|
def serializable_object(options={})
|
||||||
return nil if object.nil?
|
return nil if object.nil?
|
||||||
hash = attributes
|
hash = attributes
|
||||||
hash.merge! associations
|
hash.merge! associations
|
||||||
@options[:_wrap_in_array] ? [hash] : hash
|
@options[:_wrap_in_array] ? [hash] : hash
|
||||||
end
|
end
|
||||||
alias_method :serializable_object, :serializable_hash
|
alias_method :serializable_hash, :serializable_object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -13,7 +13,7 @@ module ActiveModel
|
|||||||
|
|
||||||
@name = name.to_s
|
@name = name.to_s
|
||||||
@options = options
|
@options = options
|
||||||
self.embed = options.fetch(:embed) { CONFIG.embed }
|
self.embed = options.fetch(:embed) { CONFIG.embed }
|
||||||
@embed_in_root = options.fetch(:embed_in_root) { options.fetch(:include) { CONFIG.embed_in_root } }
|
@embed_in_root = options.fetch(:embed_in_root) { options.fetch(:include) { CONFIG.embed_in_root } }
|
||||||
@embed_key = options[:embed_key] || :id
|
@embed_key = options[:embed_key] || :id
|
||||||
@key = options[:key]
|
@key = options[:key]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user