Backport `Enumerable#to_h` on platforms which do not support it

This adds `to_h` to all classes that support it in Ruby 2.1. It will not
override Ruby's definition on 2.1 and later.
Should this `unless` check be for every module separately? Seems more robust that way, even if latest Ruby version defines to_h in all modules at once.