summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobert <therobot.johnny5@gmail.com>2014-03-30 19:59:57 +0200
committerRyan Fitzgerald <rwfitzge@gmail.com>2014-04-27 14:11:22 -0700
commitca62cbae8067bc9bafbc35d7d064409926d93f76 (patch)
tree7b5e5d2ca0dd4caea6d4ff30d8b3c46013f2dfb7
parent7eed5115fab4db4f69c781da797fe7d6c7262a0f (diff)
downloadpry-ca62cbae8067bc9bafbc35d7d064409926d93f76.tar.gz
improve `#inspect` of Pry::Config::Behavior instances (`_pry_.config`)
closes #1150
-rw-r--r--lib/pry/config/behavior.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/pry/config/behavior.rb b/lib/pry/config/behavior.rb
index 5d2a5d35..83e04bdf 100644
--- a/lib/pry/config/behavior.rb
+++ b/lib/pry/config/behavior.rb
@@ -95,7 +95,7 @@ module Pry::Config::Behavior
def default_for(other)
if @default_for
- raise RuntimeError, "self is already the default for %s" % [Pry.view_clip(@default_for, id: true)]
+ raise RuntimeError, "self is already the default for %s" % _clip_inspect(@default)
else
@default_for = other
end
@@ -110,7 +110,17 @@ module Pry::Config::Behavior
end
alias_method :to_h, :to_hash
+
+ def inspect
+ key_str = keys.map { |key| "'#{key}'" }.join(",")
+ "<#{_clip_inspect(self)} keys=[#{key_str}] default=#{@default.inspect}>"
+ end
+
private
+ def _clip_inspect(obj)
+ "#{obj.class}:0x%x" % obj.object_id << 1
+ end
+
def _dup(value)
if NODUP.any? { |klass| klass === value }
value