mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Move ActiveModel::Serializer.embed to DSL
This commit is contained in:
parent
832a269e98
commit
32318f9daf
@ -17,11 +17,6 @@ module ActiveModel
|
|||||||
base._associations = (_associations || {}).dup
|
base._associations = (_associations || {}).dup
|
||||||
end
|
end
|
||||||
|
|
||||||
def embed(type, options={})
|
|
||||||
Configuration.global.embed = type
|
|
||||||
Configuration.global.embed_in_root = true if options[:embed_in_root] || options[:include]
|
|
||||||
end
|
|
||||||
|
|
||||||
if RUBY_VERSION >= '2.0'
|
if RUBY_VERSION >= '2.0'
|
||||||
def serializer_for(resource)
|
def serializer_for(resource)
|
||||||
if resource.respond_to?(:to_ary)
|
if resource.respond_to?(:to_ary)
|
||||||
@ -54,7 +49,7 @@ module ActiveModel
|
|||||||
|
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
|
||||||
def_delegators :dsl, :attributes, :has_one, :has_many
|
def_delegators :dsl, :attributes, :has_one, :has_many, :embed
|
||||||
|
|
||||||
def configuration
|
def configuration
|
||||||
@configuration ||= Configuration.global.build
|
@configuration ||= Configuration.global.build
|
||||||
|
|||||||
@ -25,6 +25,11 @@ module ActiveModel
|
|||||||
associate Association::HasMany, *names
|
associate Association::HasMany, *names
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def embed(type, options = {})
|
||||||
|
Configuration.global.embed = type
|
||||||
|
Configuration.global.embed_in_root = true if options[:embed_in_root] || options[:include]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def associate(klass, *names)
|
def associate(klass, *names)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user