From 6c4598bbc0d55f47dd01c896ecd2e5e3f029357f Mon Sep 17 00:00:00 2001 From: Kevin Clark Date: Wed, 18 Jun 2008 01:16:20 +0000 Subject: [PATCH] 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 --- lib/rb/lib/thrift/struct.rb | 2 +- lib/rb/spec/struct_spec.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/rb/lib/thrift/struct.rb b/lib/rb/lib/thrift/struct.rb index 30f99cb3..32f43613 100644 --- a/lib/rb/lib/thrift/struct.rb +++ b/lib/rb/lib/thrift/struct.rb @@ -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 diff --git a/lib/rb/spec/struct_spec.rb b/lib/rb/spec/struct_spec.rb index 5554497e..2ed1874b 100644 --- a/lib/rb/spec/struct_spec.rb +++ b/lib/rb/spec/struct_spec.rb @@ -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 -- 2.17.1