Check nil.to_h existance by respond_to instead of ruby version