diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-07-07 09:58:56 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-07-07 09:58:56 +0100 |
commit | b76b9e216463f045c8a5ca4b1a6a7994f2baa389 (patch) | |
tree | 71b1fa3b8438387eb955a963fcd550445398411c /activerecord/lib/active_record | |
parent | 8a6780bd34b8bb97f79b4fe2071b343478bbd547 (diff) | |
download | rails-b76b9e216463f045c8a5ca4b1a6a7994f2baa389.tar.gz rails-b76b9e216463f045c8a5ca4b1a6a7994f2baa389.tar.bz2 rails-b76b9e216463f045c8a5ca4b1a6a7994f2baa389.zip |
Simplify Relation#inspect
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index dc00448dff..0d1c9ef3e5 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -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 |