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 end
def inspect def inspect
text = if limit_value && limit_value <= 10 entries = limit([limit_value, 11].compact.min).map(&:inspect)
to_a.inspect entries[10] = '...' if entries.size == 11
else
entries = limit(11).to_a
if entries.size > 10
entries.pop
"[#{entries.map(&:inspect).join(', ')}, ...]"
else
entries.inspect
end
end
"#<#{self.class.name} #{text}>" "#<#{self.class.name} [#{entries.join(', ')}]>"
end end
private private