mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +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
|
||||
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'
|
||||
def serializer_for(resource)
|
||||
if resource.respond_to?(:to_ary)
|
||||
@ -54,7 +49,7 @@ module ActiveModel
|
||||
|
||||
extend Forwardable
|
||||
|
||||
def_delegators :dsl, :attributes, :has_one, :has_many
|
||||
def_delegators :dsl, :attributes, :has_one, :has_many, :embed
|
||||
|
||||
def configuration
|
||||
@configuration ||= Configuration.global.build
|
||||
|
||||
@ -25,6 +25,11 @@ module ActiveModel
|
||||
associate Association::HasMany, *names
|
||||
end
|
||||
|
||||
def embed(type, options = {})
|
||||
Configuration.global.embed = type
|
||||
Configuration.global.embed_in_root = true if options[:embed_in_root] || options[:include]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def associate(klass, *names)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user