提交 90e60aa4 编写于 作者: A aditya-kapoor

Added some more documentation for define_readers and define_writer of the...

Added some more documentation for define_readers and define_writer of the Association and its inherited classes
上级 da8fff52
......@@ -73,6 +73,13 @@ def valid_options
def validate_options
options.assert_valid_keys(valid_options)
end
# Defines the setter and getter methods for the association
# class Post < ActiveRecord::Base
# has_many :comments
# end
#
# Post.first.comments and Post.first.comments= methods are defined by this method...
def define_accessors
define_readers
......
# This class is inherited by the has_many and has_many_and_belongs_to_many association classes
require 'active_record/associations'
module ActiveRecord::Associations::Builder
......@@ -66,6 +68,8 @@ def define_callback(callback_name)
model.send("#{full_callback_name}=", Array(options[callback_name.to_sym]))
end
# Defines the setter and getter methods for the collection_singular_ids.
def define_readers
super
......
# This class is inherited by the has_one and belongs_to association classes
module ActiveRecord::Associations::Builder
class SingularAssociation < Association #:nodoc:
def valid_options
......@@ -13,6 +15,8 @@ def define_accessors
define_constructors if constructable?
end
# Defines the (build|create)_association methods for belongs_to or has_one association
def define_constructors
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
def build_#{name}(*args, &block)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册