aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-12-23 20:05:34 +0000
committerJon Leighton <j@jonathanleighton.com>2010-12-26 18:46:58 +0000
commitac67eee4e65082f4312976bd89bbec6f71025aa1 (patch)
tree813c8a1612fb5a16aad2e668c9343fe44af75c46 /activerecord/lib/active_record
parent739ea1fbfe704cdb25e9c2a7f0911ade7431e7f4 (diff)
downloadrails-ac67eee4e65082f4312976bd89bbec6f71025aa1.tar.gz
rails-ac67eee4e65082f4312976bd89bbec6f71025aa1.tar.bz2
rails-ac67eee4e65082f4312976bd89bbec6f71025aa1.zip
Use conditionals and implicit returns rather than explicit returns and postfix ifs (it's easier to read)
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb10
1 files changed, 7 insertions, 3 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 4a3f53d70f..4dabfe2ea3 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -21,9 +21,13 @@ module ActiveRecord
# 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.
def size
- return @owner.send(:read_attribute, cached_counter_attribute_name) if has_cached_counter?
- return @target.size if loaded?
- return count
+ if has_cached_counter?
+ @owner.send(:read_attribute, cached_counter_attribute_name)
+ elsif loaded?
+ @target.size
+ else
+ count
+ end
end
protected