diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-04 12:54:42 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-04 12:54:42 +0000 |
commit | 70ae0d2a4216a611467746d82eb857337c566f6e (patch) | |
tree | eba576fc93fda06a13e8adc7a29624429ac99170 /lib/pp.rb | |
parent | 5f22cfcc305b7da618badedc08b461b3f5454792 (diff) | |
download | ruby-70ae0d2a4216a611467746d82eb857337c566f6e.tar.gz |
Refactored using Method#owner.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/pp.rb')
-rw-r--r-- | lib/pp.rb | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -311,7 +311,7 @@ class PP < PrettyPrint inspect_method = method_method.call(:inspect) rescue NameError end - if inspect_method && /\(Kernel\)#/ !~ inspect_method.inspect + if inspect_method && inspect_method.owner != Kernel q.text self.inspect elsif !inspect_method && self.respond_to?(:inspect) q.text self.inspect @@ -345,7 +345,7 @@ class PP < PrettyPrint # However, doing this requires that every class that #inspect is called on # implement #pretty_print, or a RuntimeError will be raised. def pretty_print_inspect - if /\(PP::ObjectMixin\)#/ =~ Object.instance_method(:method).bind(self).call(:pretty_print).inspect + if Object.instance_method(:method).bind(self).call(:pretty_print).owner == PP::ObjectMixin raise "pretty_print is not overridden for #{self.class}" end PP.singleline_pp(self, ''.dup) |