diff options
author | Jon Atack <jon@atack.com> | 2014-05-06 15:19:02 +0200 |
---|---|---|
committer | Jon Atack <jonnyatack@gmail.com> | 2014-05-07 13:08:24 +0200 |
commit | 22f251832ccd227c6dc34ae6c55ebe02547d05d6 (patch) | |
tree | 33f150d829b4b53c6beb126a7198f842d0c89a42 | |
parent | cbc554be3d22bb25c95fdbbaadda20c22947b42b (diff) | |
download | rails-22f251832ccd227c6dc34ae6c55ebe02547d05d6.tar.gz rails-22f251832ccd227c6dc34ae6c55ebe02547d05d6.tar.bz2 rails-22f251832ccd227c6dc34ae6c55ebe02547d05d6.zip |
Follow-up to #14990 [ci skip]
Rewrite to avoid 'we'/'you', add missing period, and keep lines at 80 chars. Cheers :)
Improve readability with help from @senny
[ci skip]
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index cdabf02b95..0b122d2070 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -12,10 +12,11 @@ module ActiveRecord @through_association = nil end - # Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been - # loaded and calling collection.size if it has. If it's more likely than not that the collection does - # have a size larger than zero, and you need to fetch that collection afterwards, it'll take one fewer - # SELECT query if you use #length. + # Returns the size of the collection by executing a SELECT COUNT(*) query + # if the collection hasn't been loaded, and by calling collection.size if + # it has. If the collection will likely have a size greater than zero, + # and if fetching the collection will be needed afterwards, one less + # SELECT query will be generated by using #length instead. def size if has_cached_counter? owner.read_attribute cached_counter_attribute_name(reflection) @@ -72,13 +73,11 @@ module ActiveRecord @through_association ||= owner.association(through_reflection.name) end - # We temporarily cache through record that has been built, because if we build a - # through record in build_record and then subsequently call insert_record, then we - # want to use the exact same object. + # The through record (built with build_record) is temporarily cached + # so that it may be reused if insert_record is subsequently called. # - # However, after insert_record has been called, we clear the cache entry because - # we want it to be possible to have multiple instances of the same record in an - # association + # However, after insert_record has been called, the cache is cleared in + # order to allow multiple instances of the same record in an association. def build_through_record(record) @through_records[record.object_id] ||= begin ensure_mutable |