Replace to_h method with alternative.

Older version of Ruby on stage (2.0.0) doesn’t have this method.