1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Simplify Relation#inspect

This commit is contained in:
Jon Leighton 2012-07-07 09:58:56 +01:00
parent 8a6780bd34
commit b76b9e2164

View file

@ -515,19 +515,10 @@ module ActiveRecord
end
def inspect
text = if limit_value && limit_value <= 10
to_a.inspect
else
entries = limit(11).to_a
if entries.size > 10
entries.pop
"[#{entries.map(&:inspect).join(', ')}, ...]"
else
entries.inspect
end
end
entries = limit([limit_value, 11].compact.min).map(&:inspect)
entries[10] = '...' if entries.size == 11
"#<#{self.class.name} #{text}>"
"#<#{self.class.name} [#{entries.join(', ')}]>"
end
private