@@ -82,15 +82,15 @@ def truncate(name)
82
82
# Note: not all valid {Relation#select}[rdoc-ref:QueryMethods#select] expressions are valid +count+ expressions. The specifics differ
83
83
# between databases. In invalid cases, an error from the database is thrown.
84
84
#
85
- # When given a block, loads all records in the relation, if the relation
86
- # hasn't been loaded yet. Calls the block with each record in the relation.
87
- # Returns the number of records for which the block returns a truthy value.
85
+ # When given a block, calls the block with each record in the relation and
86
+ # returns the number of records for which the block returns a truthy value.
88
87
#
89
88
# Person.count { |person| person.age > 21 }
90
89
# # => counts the number of people older that 21
91
90
#
92
- # Note: If there are a lot of records in the relation, loading all records
93
- # could result in performance issues.
91
+ # If the relation hasn't been loaded yet, calling +count+ with a block will
92
+ # load all records in the relation. If there are a lot of records in the
93
+ # relation, loading all records could result in performance issues.
94
94
def count ( column_name = nil )
95
95
if block_given?
96
96
unless column_name . nil?
@@ -159,16 +159,15 @@ def async_maximum(column_name)
159
159
#
160
160
# Person.sum(:age) # => 4562
161
161
#
162
- # When given a block, loads all records in the relation, if the relation
163
- # hasn't been loaded yet. Calls the block with each record in the relation.
164
- # Returns the sum of +initial_value_or_column+ and the block return
165
- # values:
162
+ # When given a block, calls the block with each record in the relation and
163
+ # returns the sum of +initial_value_or_column+ plus the block return values:
166
164
#
167
165
# Person.sum { |person| person.age } # => 4562
168
166
# Person.sum(1000) { |person| person.age } # => 5562
169
167
#
170
- # Note: If there are a lot of records in the relation, loading all records
171
- # could result in performance issues.
168
+ # If the relation hasn't been loaded yet, calling +sum+ with a block will
169
+ # load all records in the relation. If there are a lot of records in the
170
+ # relation, loading all records could result in performance issues.
172
171
def sum ( initial_value_or_column = 0 , &block )
173
172
if block_given?
174
173
map ( &block ) . sum ( initial_value_or_column )
0 commit comments