AMS::Associations::Base is now AMS::Association. HasMany and HasOne inherits from it.

This commit is contained in:
Santiago Pastorino 2013-05-16 16:51:56 -07:00
parent 787b7cf24a
commit 055f8fe33c
2 changed files with 69 additions and 71 deletions

View File

@ -152,7 +152,7 @@ module ActiveModel
# with the association name does not exist, the association name is
# dispatched to the serialized object.
def has_many(*attrs)
associate(Associations::HasMany, attrs)
associate(Association::HasMany, attrs)
end
# Defines an association in the object should be rendered.
@ -162,7 +162,7 @@ module ActiveModel
# with the association name does not exist, the association name is
# dispatched to the serialized object.
def has_one(*attrs)
associate(Associations::HasOne, attrs)
associate(Association::HasOne, attrs)
end
# Return a schema hash for the current serializer. This information
@ -372,9 +372,9 @@ module ActiveModel
options = klass_options.merge options
klass
elsif value.respond_to?(:to_ary)
Associations::HasMany
Association::HasMany
else
Associations::HasOne
Association::HasOne
end
options = default_embed_options.merge!(options)

View File

@ -1,7 +1,6 @@
module ActiveModel
class Serializer
module Associations #:nodoc:
class Base #:nodoc:
class Association #:nodoc:
# name: The name of the association.
#
# options: A hash. These keys are accepted:
@ -71,9 +70,8 @@ module ActiveModel
object
end
end
end
class HasMany < Base #:nodoc:
class HasMany < Association #:nodoc:
def root
options[:root] || name
end
@ -101,7 +99,7 @@ module ActiveModel
end
end
class HasOne < Base #:nodoc:
class HasOne < Association #:nodoc:
def initialize(name, options={}, serializer_options={})
super
@polymorphic = options[:polymorphic]