| Jifty-DBI documentation | Contained in the Jifty-DBI distribution. |
Jifty::DBI::Filter::Storable - Encodes arbitrary data using Storable
This filter allows you to store arbitrary Perl data structures in a column of type 'blob', using Storable to serialize them.
If value is defined, then encodes it using nfreeze in Storable. Does nothing if value is not defined.
If value is defined, then decodes it using thaw in Storable, otherwise does nothing.
| Jifty-DBI documentation | Contained in the Jifty-DBI distribution. |
package Jifty::DBI::Filter::Storable; use warnings; use strict; use base qw|Jifty::DBI::Filter|; use Storable ();
sub encode { my $self = shift; my $value_ref = $self->value_ref; return unless defined $$value_ref; $Storable::Deparse = 1; $$value_ref = Storable::nfreeze($value_ref); }
sub decode { my $self = shift; my $value_ref = $self->value_ref; return unless defined $$value_ref; # Storable doesn't take Unicode strings. Encode::_utf8_off($$value_ref); local $@; $Storable::Eval = 1; $$value_ref = eval { ${ Storable::thaw($$value_ref) } }; }
1;