From 6a75a460536a32fb62184dc5d8d66ddd737a9bad Mon Sep 17 00:00:00 2001 From: Richard Viney Date: Sun, 22 Jan 2017 14:50:08 +1300 Subject: Make prettyprint’s cycle detection aware of Delegator instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes [Bug #13144] Co-Authored-By: Nobuyoshi Nakada --- lib/pp.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/pp.rb b/lib/pp.rb index 2cfc2c4009..81a9a1629c 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -149,6 +149,10 @@ class PP < PrettyPrint # Object#pretty_print_cycle is used when +obj+ is already # printed, a.k.a the object reference chain has a cycle. def pp(obj) + # If obj is a Delegator then use the object being delegated to for cycle + # detection + obj = obj.__getobj__ if defined?(::Delegator) and obj.is_a?(::Delegator) + if check_inspect_key(obj) group {obj.pretty_print_cycle self} return -- cgit v1.2.3