Move ActiveModel::Serializer.embed to DSL

This commit is contained in:
Adrian Mugnolo and Santiago Pastorino 2014-01-13 14:15:05 -02:00 committed by Santiago Pastorino
parent 832a269e98
commit 32318f9daf
2 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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)