<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: What is the right way to serialize X object generically?</title>
	<atom:link href="http://blog.afoolishmanifesto.com/archives/1269/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.afoolishmanifesto.com/archives/1269</link>
	<description>fREWdiculous!</description>
	<lastBuildDate>Mon, 16 Jan 2012 12:16:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: anonymous coward</title>
		<link>http://blog.afoolishmanifesto.com/archives/1269/comment-page-1#comment-964</link>
		<dc:creator>anonymous coward</dc:creator>
		<pubDate>Thu, 21 Jan 2010 10:31:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=1269#comment-964</guid>
		<description>Set up a typemap to reuse the Storable hooks of a class. See KiokuDB::TypeMap::Default and KiokuDB::TypeMap::Entry::Passthrough and ack for DateTime.</description>
		<content:encoded><![CDATA[<p>Set up a typemap to reuse the Storable hooks of a class. See KiokuDB::TypeMap::Default and KiokuDB::TypeMap::Entry::Passthrough and ack for DateTime.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Kennedy</title>
		<link>http://blog.afoolishmanifesto.com/archives/1269/comment-page-1#comment-960</link>
		<dc:creator>Adam Kennedy</dc:creator>
		<pubDate>Thu, 21 Jan 2010 04:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=1269#comment-960</guid>
		<description>Crap, broken indenting...</description>
		<content:encoded><![CDATA[<p>Crap, broken indenting&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Kennedy</title>
		<link>http://blog.afoolishmanifesto.com/archives/1269/comment-page-1#comment-959</link>
		<dc:creator>Adam Kennedy</dc:creator>
		<pubDate>Thu, 21 Jan 2010 03:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=1269#comment-959</guid>
		<description>Don&#039;t monkey patch...

If you have defined your own private serialisation scheme, then you can define your own set of special casing.

my @SPECIAL = (
    [
        &#039;DateTime&#039;,
        sub { to json },
        sub { from_json } ],
    ],
    [
        ...
    ],
);

then later...

if ( $instance-&gt;can(&#039;TO_JSON&#039;) ) {
     return $instance-&gt;TO_JSON;
}
my $special = first {
    $instance-&gt;isa($_-&gt;[0])
} @SPECIAL;
if ( $special ) {
    return $special-&gt;[1]-&gt;( $instance );
}</description>
		<content:encoded><![CDATA[<p>Don&#8217;t monkey patch&#8230;</p>
<p>If you have defined your own private serialisation scheme, then you can define your own set of special casing.</p>
<p>my @SPECIAL = (<br />
    [<br />
        'DateTime',<br />
        sub { to json },<br />
        sub { from_json } ],<br />
    ],<br />
    [<br />
        ...<br />
    ],<br />
);</p>
<p>then later&#8230;</p>
<p>if ( $instance-&gt;can(&#8216;TO_JSON&#8217;) ) {<br />
     return $instance-&gt;TO_JSON;<br />
}<br />
my $special = first {<br />
    $instance-&gt;isa($_-&gt;[0])<br />
} @SPECIAL;<br />
if ( $special ) {<br />
    return $special-&gt;[1]-&gt;( $instance );<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

