rb: Struct#new should properly initialize boolean values
authorKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:16:20 +0000 (01:16 +0000)
committerKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:16:20 +0000 (01:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@669001 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/lib/thrift/struct.rb
lib/rb/spec/struct_spec.rb

index 30f99cb..32f4361 100644 (file)
@@ -4,7 +4,7 @@ module Thrift
   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
 
index 5554497..2ed1874 100644 (file)
@@ -49,10 +49,8 @@ class ThriftStructSpec < Spec::ExampleGroup
   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