Module: PP::PPMethods
- Defined in:
- lib/qonfig/plugins/pretty_print/ruby_2_7_basic_object_pp_patch.rb
Overview
Instance Method Summary collapse
-
#pp(obj) ⇒ Object
:nocov:.
Instance Method Details
#pp(obj) ⇒ Object
:nocov:
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/qonfig/plugins/pretty_print/ruby_2_7_basic_object_pp_patch.rb', line 12 def pp(obj) # If obj is a Delegator then use the object being delegated to for cycle # detection # NOTE: --- PATCH --- if defined?(::Delegator) and ( begin (class << obj; self; end) <= ::Delegator # patch rescue ::TypeError obj.is_a?(::Delegator) end ) obj = obj.__getobj__ end # instead of: obj = obj.__getobj__ if defined?(::Delegator) and obj.is_a?(::Delegator) # NOTE: # Old implementation can not be used with BasicObject instances # (with Qonfig::Compacted in our case) # NOTE: --- PATCH --- if check_inspect_key(obj) group { obj.pretty_print_cycle self } return end begin push_inspect_key(obj) group { obj.pretty_print self } ensure pop_inspect_key(obj) unless PP.sharing_detection end end |