rb: Struct#new should properly initialize boolean values
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@669001 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/lib/thrift/struct.rb b/lib/rb/lib/thrift/struct.rb
index 30f99cb..32f4361 100644
--- a/lib/rb/lib/thrift/struct.rb
+++ b/lib/rb/lib/thrift/struct.rb
@@ -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
diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb
index 5554497..2ed1874 100644
--- a/lib/rb/spec/struct_spec.rb
+++ b/lib/rb/spec/struct_spec.rb
@@ -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