mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/pp.rb (PP::PPMethods#guard_inspect_key): support
__recursive_key__. [ruby-dev:25821] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
827a62edd7
commit
7935361d36
2 changed files with 19 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Mar 9 23:55:34 2005 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
|
* lib/pp.rb (PP::PPMethods#guard_inspect_key): support
|
||||||
|
__recursive_key__. [ruby-dev:25821]
|
||||||
|
|
||||||
Wed Mar 9 19:42:21 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
Wed Mar 9 19:42:21 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
* ext/openssl/ossl_ssl.c: OpenSSL::SSL::SSLContexts suports callbacks:
|
* ext/openssl/ossl_ssl.c: OpenSSL::SSL::SSLContexts suports callbacks:
|
||||||
|
|
24
lib/pp.rb
24
lib/pp.rb
|
@ -91,31 +91,35 @@ class PP < PrettyPrint
|
||||||
end
|
end
|
||||||
|
|
||||||
module PPMethods
|
module PPMethods
|
||||||
InspectKey = :__inspect_key__
|
|
||||||
|
|
||||||
def guard_inspect_key
|
def guard_inspect_key
|
||||||
if Thread.current[InspectKey] == nil
|
if Thread.current[:__recursive_key__] == nil
|
||||||
Thread.current[InspectKey] = {inspect: []}
|
Thread.current[:__recursive_key__] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
save = Thread.current[InspectKey][:inspect]
|
if Thread.current[:__recursive_key__][:inspect] == nil
|
||||||
|
Thread.current[:__recursive_key__][:inspect] = []
|
||||||
|
end
|
||||||
|
|
||||||
|
save = Thread.current[:__recursive_key__][:inspect]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Thread.current[InspectKey][:inspect] = []
|
Thread.current[:__recursive_key__][:inspect] = []
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
Thread.current[InspectKey][:inspect] = save
|
Thread.current[:__recursive_key__][:inspect] = save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_inspect_key(id)
|
def check_inspect_key(id)
|
||||||
Thread.current[InspectKey][:inspect].include?(id)
|
Thread.current[:__recursive_key__] &&
|
||||||
|
Thread.current[:__recursive_key__][:inspect] &&
|
||||||
|
Thread.current[:__recursive_key__][:inspect].include?(id)
|
||||||
end
|
end
|
||||||
def push_inspect_key(id)
|
def push_inspect_key(id)
|
||||||
Thread.current[InspectKey][:inspect] << id
|
Thread.current[:__recursive_key__][:inspect] << id
|
||||||
end
|
end
|
||||||
def pop_inspect_key
|
def pop_inspect_key
|
||||||
Thread.current[InspectKey][:inspect].pop
|
Thread.current[:__recursive_key__][:inspect].pop
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds +obj+ to the pretty printing buffer
|
# Adds +obj+ to the pretty printing buffer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue