def initialize(d={})
each_field do |fid, type, name, default|
value = d.delete(name.to_s) { d.delete(name.to_sym) { default.dup rescue default } }
- Thrift.check_type(value, type)
+ Thrift.check_type(value, type) if Thrift.type_checking
instance_variable_set("@#{name}", value)
end
raise Exception, "Unknown keys given to #{self.class}.new: #{d.keys.join(", ")}" unless d.empty?
fields.each do |field|
klass.send :attr_reader, field
klass.send :define_method, "#{field}=" do |value|
- Thrift.check_type(value, klass::FIELDS.values.find { |f| f[:name].to_s == field.to_s }[:type] )
+ Thrift.check_type(value, klass::FIELDS.values.find { |f| f[:name].to_s == field.to_s }[:type] ) if Thrift.type_checking
instance_variable_set("@#{field}", value)
end
end
end
it "should be disabled when Thrift.type_checking = false" do
+ pending "disabled, parents should check Thrift.type_checking"
Thrift.type_checking = false
lambda { Thrift.check_type(3, Types::STRING) }.should_not raise_error(TypeError)
end