Permalink
Browse files

Simplify Relation#inspect

  • Loading branch information...
1 parent 8a6780b commit b76b9e216463f045c8a5ca4b1a6a7994f2baa389 @jonleighton jonleighton committed Jul 7, 2012
Showing with 3 additions and 12 deletions.
  1. +3 −12 activerecord/lib/active_record/relation.rb
@@ -515,19 +515,10 @@ def values
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

0 comments on commit b76b9e2

Please sign in to comment.