Problem
Normal objects serialize to something like:
"--- !ruby/object {}\n\n"
whereas Mail::Message serialize to:
"--- \nMime-Version: \"1.0\"\nbody: \"\"\nContent-Transfer-Encoding:[…]"
Question
How can I have Mail::Message serialized just like other objects?
Background
Gem Versions:
- YAML: “0.60”
- Mail: “2.2.19”
Code
Object.new.to_yaml #gives
"--- !ruby/object {}\n\n"
Mail::Message.new.to_yaml #gives
"--- \nMime-Version: \"1.0\"\nbody: \"\"\nContent-Transfer-Encoding: 7bit\nMessage-ID: <4dc418052be4a_16b62850c31ac91488@mbp.local.mail>\nsubject: \nContent-Type: text/plain\nDate: Fri, 06 May 2011 15:47:17 +0000\n"
Desired output
"--- !ruby/object:Mail::Message {}\n\n"
The reason was a flawed patch to the Mail gem. Details are outlined here:
https://github.com/mikel/mail/pull/237