Implement required #encode_with

While running the spec `ARCONN=mysql2 ruby -v -Itest test/cases/yaml_serialization_test.rb`
the following warning shows up:
`implementing to_yaml is deprecated, please implement "encode_with"`

That's fixed on this PR.
What's the reason for this line being added?