[#1491] bug — Mathieu Bouchard <matju@...>
6 messages
2003/09/01
[#1492] non-blocking mode behavior (Re: bug)
— nobu.nokada@...
2003/09/01
Hi,
[#1512] New tests — Dave Thomas <Dave@...>
I was looking through the new test/ruby/* stuff just now, and notices
6 messages
2003/09/05
[#1533] GC disable / enable question — Torsten Rueger <torsten.rueger@...>
Moi,
7 messages
2003/09/17
[#1534] Re: GC disable / enable question
— nobu.nokada@...
2003/09/17
Hi,
[#1541] How to debug ? — Torsten Rueger <torsten.rueger@...>
Moi,
6 messages
2003/09/19
[#1542] Re: How to debug ?
— ts <decoux@...>
2003/09/19
>>>>> "T" == Torsten Rueger <torsten.rueger@hiit.fi> writes:
[#1551] Hashes as keys — "Nathaniel Talbott" <nathaniel@...>
I was just playing around with Hash#hash and discovered that you can't use a
13 messages
2003/09/23
[#1552] Re: Hashes as keys
— Jim Freeze <jim@...>
2003/09/23
On Wednesday, 24 September 2003 at 6:21:33 +0900, Nathaniel Talbott wrote:
[#1556] ostruct.rb patch — "Nathaniel Talbott" <nathaniel@...>
I've been finding OpenStruct to be very useful lately, and then I discovered
9 messages
2003/09/24
[#1557] Re: ostruct.rb patch
— "NAKAMURA, Hiroshi" <nahi@...>
2003/09/24
Hi, Nathaniel,
Re: ostruct.rb patch
From:
"Nathaniel Talbott" <nathaniel@...>
Date:
2003-09-24 19:48:35 UTC
List:
ruby-core #1571
Yukihiro Matsumoto [mailto:matz@ruby-lang.org] wrote:
> Show me the latest diff. I think I will agree to apply it.
Here it is. I've dropped the #hash method, and changed to using a protected
method to access the table.
Let me know what you think,
Nathaniel
<:((><
Index: lib/ostruct.rb
===================================================================
RCS file: /src/ruby/lib/ostruct.rb,v
retrieving revision 1.7
diff -u -w -r1.7 ostruct.rb
--- lib/ostruct.rb 26 Aug 2003 14:54:51 -0000 1.7
+++ lib/ostruct.rb 24 Sep 2003 19:47:40 -0000
@@ -48,4 +48,12 @@
end
str << ">"
end
+
+ attr_reader :table
+ protected :table
+
+ def ==(other)
+ return false unless(other.kind_of?(OpenStruct))
+ return @table == other.table
+ end
end
Index: test/ostruct/test_ostruct.rb
===================================================================
RCS file: test/ostruct/test_ostruct.rb
diff -N test/ostruct/test_ostruct.rb
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/ostruct/test_ostruct.rb 24 Sep 2003 19:47:40 -0000
@@ -0,0 +1,23 @@
+require 'test/unit'
+require 'ostruct'
+
+class TC_OpenStruct < Test::Unit::TestCase
+ def test_equality
+ o1 = OpenStruct.new
+ o2 = OpenStruct.new
+ assert_equal(o1, o2)
+
+ o1.a = 'a'
+ assert_not_equal(o1, o2)
+
+ o2.a = 'a'
+ assert_equal(o1, o2)
+
+ o1.a = 'b'
+ assert_not_equal(o1, o2)
+
+ o2 = Object.new
+ o2.instance_eval{@table = {:a => 'b'}}
+ assert_not_equal(o1, o2)
+ end
+end