Author: kclark
Date: Tue Jun 17 18:16:20 2008
New Revision: 669001

URL: http://svn.apache.org/viewvc?rev=669001&view=rev
Log:
rb: Struct#new should properly initialize boolean values

Modified:
    incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
    incubator/thrift/trunk/lib/rb/spec/struct_spec.rb

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb?rev=669001&r1=669000&r2=669001&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb Tue Jun 17 18:16:20 2008
@@ -4,7 +4,7 @@
   module Struct
     def initialize(d={})
       each_field do |fid, type, name, default|
-        instance_variable_set("@#{name}", d[name.to_s] || d[name.intern] || 
(default.dup rescue default))
+        instance_variable_set("@#{name}", d.fetch(name.to_s) { 
d.fetch(name.to_sym) { default.dup rescue default } })
       end
     end
 

Modified: incubator/thrift/trunk/lib/rb/spec/struct_spec.rb
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/struct_spec.rb?rev=669001&r1=669000&r2=669001&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/struct_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/struct_spec.rb Tue Jun 17 18:16:20 2008
@@ -49,10 +49,8 @@
   end
 
   it "should properly initialize boolean values" do
-    pending do
-      struct = BoolStruct.new(:yesno => false)
-      struct.yesno.should be_false
-    end
+    struct = BoolStruct.new(:yesno => false)
+    struct.yesno.should be_false
   end
 
   it "should have proper == semantics" do


Reply via email to