Fix a Ruby version compatibility problem

In old Ruby (e.g. 1.8.5), there is no "instance_variable_defined?"
function for reflection, so we use "defined?" instead.