NAME
MooseX::Storage::DBIC - Additional MooseX::Storage functionality for DBIx::Class rows and data structures.
SYNOPSIS
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);
WARNINGS
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.