From 0e20e3ebc20250174867f33e0ad3972f7e7c76d0 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Fri, 30 Jul 2010 14:43:13 -0400 Subject: returns not returned . fixing documentation for reflection --- activerecord/lib/active_record/reflection.rb | 58 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 09d7f8699e..03a932f642 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -3,14 +3,14 @@ module ActiveRecord module Reflection # :nodoc: extend ActiveSupport::Concern - # Reflection allows you to interrogate Active Record classes and objects + # Reflection enables to interrogate Active Record classes and objects # about their associations and aggregations. This information can, - # for example, be used in a form builder that took an Active Record object - # and created input fields for all of the attributes depending on their type - # and displayed the associations to other objects. + # for example, be used in a form builder that takes an Active Record object + # and creates input fields for all of the attributes depending on their type + # and displays the associations to other objects. # - # You can find the interface for the AggregateReflection and AssociationReflection - # classes in the abstract MacroReflection class. + # MacroReflection class has info for AggregateReflection and AssociationReflection + # classes. module ClassMethods def create_reflection(macro, name, options, active_record) case macro @@ -24,7 +24,7 @@ module ActiveRecord reflection end - # Returns a hash containing all AssociationReflection objects for the current class + # Returns a hash containing all AssociationReflection objects for the current class. # Example: # # Invoice.reflections @@ -39,9 +39,9 @@ module ActiveRecord reflections.values.select { |reflection| reflection.is_a?(AggregateReflection) } end - # Returns the AggregateReflection object for the named +aggregation+ (use the symbol). Example: + # Returns the AggregateReflection object for the named +aggregation+ (use the symbol). # - # Account.reflect_on_aggregation(:balance) # returns the balance AggregateReflection + # Account.reflect_on_aggregation(:balance) #=> the balance AggregateReflection # def reflect_on_aggregation(aggregation) reflections[aggregation].is_a?(AggregateReflection) ? reflections[aggregation] : nil @@ -78,8 +78,7 @@ module ActiveRecord end - # Abstract base class for AggregateReflection and AssociationReflection that - # describes the interface available for both of those classes. Objects of + # Abstract base class for AggregateReflection and AssociationReflection. Objects of # AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods. class MacroReflection attr_reader :active_record @@ -89,36 +88,41 @@ module ActiveRecord end # Returns the name of the macro. - # composed_of :balance, :class_name => 'Money' will return :balance - # has_many :clients will return :clients + # + # composed_of :balance, :class_name => 'Money' returns :balance + # has_many :clients returns :clients def name @name end # Returns the macro type. - # composed_of :balance, :class_name => 'Money' will return :composed_of - # has_many :clients will return :has_many + # + # composed_of :balance, :class_name => 'Money' returns :composed_of + # has_many :clients returns :has_many def macro @macro end # Returns the hash of options used for the macro. - # composed_of :balance, :class_name => 'Money' will return { :class_name => "Money" } - # has_many :clients will return +{}+ + # + # composed_of :balance, :class_name => 'Money' returns { :class_name => "Money" } + # has_many :clients returns +{}+ def options @options end # Returns the class for the macro. - # composed_of :balance, :class_name => 'Money' will return the Money class - # has_many :clients will return the Client class + # + # composed_of :balance, :class_name => 'Money' returns the Money class + # has_many :clients returns the Client class def klass @klass ||= class_name.constantize end # Returns the class name for the macro. - # composed_of :balance, :class_name => 'Money' will return 'Money' - # has_many :clients will return 'Client' + # + # composed_of :balance, :class_name => 'Money' returns 'Money' + # has_many :clients returns 'Client' def class_name @class_name ||= options[:class_name] || derive_class_name end @@ -153,7 +157,7 @@ module ActiveRecord # Holds all the meta-data about an association as it was specified in the # Active Record class. class AssociationReflection < MacroReflection #:nodoc: - # Returns the target association's class: + # Returns the target association's class. # # class Author < ActiveRecord::Base # has_many :books @@ -162,7 +166,7 @@ module ActiveRecord # Author.reflect_on_association(:books).klass # # => Book # - # Note: do not call +klass.new+ or +klass.create+ to instantiate + # Note: Do not call +klass.new+ or +klass.create+ to instantiate # a new association object. Use +build_association+ or +create_association+ # instead. This allows plugins to hook into association object creation. def klass @@ -273,7 +277,7 @@ module ActiveRecord end # Returns whether or not this association reflection is for a collection - # association. Returns +true+ if the +macro+ is one of +has_many+ or + # association. Returns +true+ if the +macro+ is either +has_many+ or # +has_and_belongs_to_many+, +false+ otherwise. def collection? @collection @@ -283,7 +287,7 @@ module ActiveRecord # the parent's validation. # # Unless you explicitly disable validation with - # :validate => false, it will take place when: + # :validate => false, validation will take place when: # # * you explicitly enable validation; :validate => true # * you use autosave; :autosave => true @@ -327,8 +331,6 @@ module ActiveRecord # Gets the source of the through reflection. It checks both a singularized # and pluralized form for :belongs_to or :has_many. # - # (The :tags association on Tagging below.) - # # class Post < ActiveRecord::Base # has_many :taggings # has_many :tags, :through => :taggings @@ -339,7 +341,7 @@ module ActiveRecord end # Returns the AssociationReflection object specified in the :through option - # of a HasManyThrough or HasOneThrough association. Example: + # of a HasManyThrough or HasOneThrough association. # # class Post < ActiveRecord::Base # has_many :taggings -- cgit v1.2.3