Skip to content

Commit 0e20e3e

Browse files
author
Neeraj Singh
committed
returns not returned . fixing documentation for reflection
1 parent 8828651 commit 0e20e3e

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

activerecord/lib/active_record/reflection.rb

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module ActiveRecord
33
module Reflection # :nodoc:
44
extend ActiveSupport::Concern
55

6-
# Reflection allows you to interrogate Active Record classes and objects
6+
# Reflection enables to interrogate Active Record classes and objects
77
# about their associations and aggregations. This information can,
8-
# for example, be used in a form builder that took an Active Record object
9-
# and created input fields for all of the attributes depending on their type
10-
# and displayed the associations to other objects.
8+
# for example, be used in a form builder that takes an Active Record object
9+
# and creates input fields for all of the attributes depending on their type
10+
# and displays the associations to other objects.
1111
#
12-
# You can find the interface for the AggregateReflection and AssociationReflection
13-
# classes in the abstract MacroReflection class.
12+
# MacroReflection class has info for AggregateReflection and AssociationReflection
13+
# classes.
1414
module ClassMethods
1515
def create_reflection(macro, name, options, active_record)
1616
case macro
@@ -24,7 +24,7 @@ def create_reflection(macro, name, options, active_record)
2424
reflection
2525
end
2626

27-
# Returns a hash containing all AssociationReflection objects for the current class
27+
# Returns a hash containing all AssociationReflection objects for the current class.
2828
# Example:
2929
#
3030
# Invoice.reflections
@@ -39,9 +39,9 @@ def reflect_on_all_aggregations
3939
reflections.values.select { |reflection| reflection.is_a?(AggregateReflection) }
4040
end
4141

42-
# Returns the AggregateReflection object for the named +aggregation+ (use the symbol). Example:
42+
# Returns the AggregateReflection object for the named +aggregation+ (use the symbol).
4343
#
44-
# Account.reflect_on_aggregation(:balance) # returns the balance AggregateReflection
44+
# Account.reflect_on_aggregation(:balance) #=> the balance AggregateReflection
4545
#
4646
def reflect_on_aggregation(aggregation)
4747
reflections[aggregation].is_a?(AggregateReflection) ? reflections[aggregation] : nil
@@ -78,8 +78,7 @@ def reflect_on_all_autosave_associations
7878
end
7979

8080

81-
# Abstract base class for AggregateReflection and AssociationReflection that
82-
# describes the interface available for both of those classes. Objects of
81+
# Abstract base class for AggregateReflection and AssociationReflection. Objects of
8382
# AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods.
8483
class MacroReflection
8584
attr_reader :active_record
@@ -89,36 +88,41 @@ def initialize(macro, name, options, active_record)
8988
end
9089

9190
# Returns the name of the macro.
92-
# <tt>composed_of :balance, :class_name => 'Money'</tt> will return <tt>:balance</tt>
93-
# <tt>has_many :clients</tt> will return <tt>:clients</tt>
91+
#
92+
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:balance</tt>
93+
# <tt>has_many :clients</tt> returns <tt>:clients</tt>
9494
def name
9595
@name
9696
end
9797

9898
# Returns the macro type.
99-
# <tt>composed_of :balance, :class_name => 'Money'</tt> will return <tt>:composed_of</tt>
100-
# <tt>has_many :clients</tt> will return <tt>:has_many</tt>
99+
#
100+
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:composed_of</tt>
101+
# <tt>has_many :clients</tt> returns <tt>:has_many</tt>
101102
def macro
102103
@macro
103104
end
104105

105106
# Returns the hash of options used for the macro.
106-
# <tt>composed_of :balance, :class_name => 'Money'</tt> will return <tt>{ :class_name => "Money" }</tt>
107-
# <tt>has_many :clients</tt> will return +{}+
107+
#
108+
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>{ :class_name => "Money" }</tt>
109+
# <tt>has_many :clients</tt> returns +{}+
108110
def options
109111
@options
110112
end
111113

112114
# Returns the class for the macro.
113-
# <tt>composed_of :balance, :class_name => 'Money'</tt> will return the Money class
114-
# <tt>has_many :clients</tt> will return the Client class
115+
#
116+
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns the Money class
117+
# <tt>has_many :clients</tt> returns the Client class
115118
def klass
116119
@klass ||= class_name.constantize
117120
end
118121

119122
# Returns the class name for the macro.
120-
# <tt>composed_of :balance, :class_name => 'Money'</tt> will return <tt>'Money'</tt>
121-
# <tt>has_many :clients</tt> will return <tt>'Client'</tt>
123+
#
124+
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>'Money'</tt>
125+
# <tt>has_many :clients</tt> returns <tt>'Client'</tt>
122126
def class_name
123127
@class_name ||= options[:class_name] || derive_class_name
124128
end
@@ -153,7 +157,7 @@ class AggregateReflection < MacroReflection #:nodoc:
153157
# Holds all the meta-data about an association as it was specified in the
154158
# Active Record class.
155159
class AssociationReflection < MacroReflection #:nodoc:
156-
# Returns the target association's class:
160+
# Returns the target association's class.
157161
#
158162
# class Author < ActiveRecord::Base
159163
# has_many :books
@@ -162,7 +166,7 @@ class AssociationReflection < MacroReflection #:nodoc:
162166
# Author.reflect_on_association(:books).klass
163167
# # => Book
164168
#
165-
# <b>Note:</b> do not call +klass.new+ or +klass.create+ to instantiate
169+
# <b>Note:</b> Do not call +klass.new+ or +klass.create+ to instantiate
166170
# a new association object. Use +build_association+ or +create_association+
167171
# instead. This allows plugins to hook into association object creation.
168172
def klass
@@ -273,7 +277,7 @@ def polymorphic_inverse_of(associated_class)
273277
end
274278

275279
# Returns whether or not this association reflection is for a collection
276-
# association. Returns +true+ if the +macro+ is one of +has_many+ or
280+
# association. Returns +true+ if the +macro+ is either +has_many+ or
277281
# +has_and_belongs_to_many+, +false+ otherwise.
278282
def collection?
279283
@collection
@@ -283,7 +287,7 @@ def collection?
283287
# the parent's validation.
284288
#
285289
# Unless you explicitly disable validation with
286-
# <tt>:validate => false</tt>, it will take place when:
290+
# <tt>:validate => false</tt>, validation will take place when:
287291
#
288292
# * you explicitly enable validation; <tt>:validate => true</tt>
289293
# * you use autosave; <tt>:autosave => true</tt>
@@ -327,8 +331,6 @@ class ThroughReflection < AssociationReflection #:nodoc:
327331
# Gets the source of the through reflection. It checks both a singularized
328332
# and pluralized form for <tt>:belongs_to</tt> or <tt>:has_many</tt>.
329333
#
330-
# (The <tt>:tags</tt> association on Tagging below.)
331-
#
332334
# class Post < ActiveRecord::Base
333335
# has_many :taggings
334336
# has_many :tags, :through => :taggings
@@ -339,7 +341,7 @@ def source_reflection
339341
end
340342

341343
# Returns the AssociationReflection object specified in the <tt>:through</tt> option
342-
# of a HasManyThrough or HasOneThrough association. Example:
344+
# of a HasManyThrough or HasOneThrough association.
343345
#
344346
# class Post < ActiveRecord::Base
345347
# has_many :taggings

0 commit comments

Comments
 (0)