Support has_one to be compatible with 0.8.x

Update README and CHANGELOG
This commit is contained in:
Gary Gordon
2014-11-06 14:54:16 -05:00
parent 77fb050d24
commit 651b99f22e
6 changed files with 66 additions and 7 deletions

View File

@@ -66,6 +66,16 @@ module ActiveModel
associate(:belongs_to, attrs)
end
# Defines an association in the object should be rendered.
#
# The serializer object should implement the association name
# as a method which should return an object when invoked. If a method
# with the association name does not exist, the association name is
# dispatched to the serialized object.
def self.has_one(*attrs)
associate(:has_one, attrs)
end
def self.associate(type, attrs) #:nodoc:
options = attrs.extract_options!
self._associations = _associations.dup