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:
parent
8a6780bd34
commit
b76b9e2164
1 changed files with 3 additions and 12 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue