MooseX::Storage::DBIC - Additional MooseX::Storage functionality for DBIx::Class rows and data structures.
package My::Schema::Result::Chair; # moose attribute we would like to serialize has 'legs' => ( is => 'rw', isa => 'Int', default => 4 ); # column to serialize __PACKAGE__->add_columns( "id" => { data_type => "integer" }, ); # relationship to serialize __PACKAGE__->belongs_to("table" => "My::Schema::Result::Table", { chair_id => "id" }); # field+method to serialize sub is_broken { return $self->{is_broken} } # declare fields to serialize with 'MooseX::Storage::DBIC'; sub schema { return $myschema } __PACKAGE__->serializable(qw/ id legs table is_broken /); # convert an instance into a hashref my $row = $myschema->resultset('Chair')->first; my $serialized = $row->pack; # convert hashref back into instance my $orig_row = My::Schema::Result::Chair->unpack($serialized);
WARNING: This software is highly experimental and untested. Do not rely on it for anything important. Bug reports and pull requests welcome.
Please also note that you cannot serialize cyclic references or cyclic relationships.
To install MooseX::Storage::DBIC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Storage::DBIC
CPAN shell
perl -MCPAN -e shell install MooseX::Storage::DBIC
For more information on module installation, please visit the detailed CPAN module installation guide.