зеркало из https://github.com/github/ruby.git
Refactored using Method#owner.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5f22cfcc30
Коммит
70ae0d2a42
|
@ -311,7 +311,7 @@ class PP < PrettyPrint
|
||||||
inspect_method = method_method.call(:inspect)
|
inspect_method = method_method.call(:inspect)
|
||||||
rescue NameError
|
rescue NameError
|
||||||
end
|
end
|
||||||
if inspect_method && /\(Kernel\)#/ !~ inspect_method.inspect
|
if inspect_method && inspect_method.owner != Kernel
|
||||||
q.text self.inspect
|
q.text self.inspect
|
||||||
elsif !inspect_method && self.respond_to?(:inspect)
|
elsif !inspect_method && self.respond_to?(:inspect)
|
||||||
q.text self.inspect
|
q.text self.inspect
|
||||||
|
@ -345,7 +345,7 @@ class PP < PrettyPrint
|
||||||
# However, doing this requires that every class that #inspect is called on
|
# However, doing this requires that every class that #inspect is called on
|
||||||
# implement #pretty_print, or a RuntimeError will be raised.
|
# implement #pretty_print, or a RuntimeError will be raised.
|
||||||
def pretty_print_inspect
|
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}"
|
raise "pretty_print is not overridden for #{self.class}"
|
||||||
end
|
end
|
||||||
PP.singleline_pp(self, ''.dup)
|
PP.singleline_pp(self, ''.dup)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче