You can use class as Class without transform it to string. Also you can use `<<` instead of `insert(-1, value)`

```ruby
rv << case v.class
   when Hash  then sanitize_hash(v)
   when Array  then sanitize_array(v)
   else v
end