提交 ac67eee4 编写于 作者: J Jon Leighton

Use conditionals and implicit returns rather than explicit returns and postfix...

Use conditionals and implicit returns rather than explicit returns and postfix ifs (it's easier to read)
上级 739ea1fb
......@@ -21,9 +21,13 @@ def destroy(*records)
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册