summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorwyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-10 14:50:32 +0000
committerwyhaines <wyhaines@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-10 14:50:32 +0000
commit69c8bf73294c1b99389b8e81f7003a88c67ff4cc (patch)
tree553ab1b27bbe1be02df9239ea5c56bedc7af9cf0 /lib
parente803164d252346a9631da26de8a9460dfd411957 (diff)
Fixed ostruct recursion inspection.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@24025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/ostruct.rb24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index 6af5bbdac0..ba7f061a22 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -111,25 +111,23 @@ class OpenStruct
def inspect
str = "#<#{self.class}"
- Thread.current[InspectKey] ||= []
- if Thread.current[InspectKey].include?(self) then
- str << " ..."
- else
+ ids = (Thread.current[InspectKey] ||= [])
+ if ids.include?(object_id)
+ return str << ' ...>'
+ end
+
+ ids << object_id
+ begin
first = true
for k,v in @table
str << "," unless first
first = false
-
- Thread.current[InspectKey] << v
- begin
- str << " #{k}=#{v.inspect}"
- ensure
- Thread.current[InspectKey].pop
- end
+ str << " #{k}=#{v.inspect}"
end
+ return str << '>'
+ ensure
+ ids.pop
end
-
- str << ">"
end
alias :to_s :inspect