Why have a class and an instance method of `to_hash`?