1 package CGI::Session::Serialize::yaml;
4 use CGI::Session::ErrorHandler;
6 $CGI::Session::Serialize::yaml::VERSION = '4.20';
7 @CGI::Session::Serialize::yaml::ISA = ( "CGI::Session::ErrorHandler" );
11 my $package = (grep { eval("use $_ (); 1;") } qw(YAML::Syck YAML))[0]
12 or die "Either YAML::Syck or YAML are required to use ", __PACKAGE__;
17 my ($self, $data) = @_;
18 return $Flavour->can('Dump')->($data);
23 my ($self, $string) = @_;
24 return ($Flavour->can('Load')->($string))[0];
35 CGI::Session::Serialize::yaml - serializer for CGI::Session
39 This library can be used by CGI::Session to serialize session data. It uses
40 L<YAML|YAML>, or the faster C implementation, L<YAML::Syck|YAML::Syck>
41 if it is available. YAML serializers exist not just for Perl but also other
42 dynamic languages, such as PHP, Python, and Ruby, so storing session data
43 in this format makes it easy to share session data across different languages.
45 YAML is made to be friendly for humans to parse as well as other computer
46 languages. It creates a format that is easier to read than the default
53 =item freeze($class, \%hash)
55 Receives two arguments. First is the class name, the second is the data to be serialized. Should return serialized string on success, undef on failure. Error message should be set using C<set_error()|CGI::Session::ErrorHandler/"set_error()">
57 =item thaw($class, $string)
59 Received two arguments. First is the class name, second is the I<YAML> data string. Should return thawed data structure on success, undef on failure. Error message should be set using C<set_error()|CGI::Session::ErrorHandler/"set_error()">
65 L<CGI::Session>, L<YAML>, L<YAML::Syck>.