Class-Workflow
view release on metacpan or search on metacpan
examples/dbic/lib/Foo/DB/Workflow/Instance.pm view on Meta::CPAN
#!/usr/bin/perl
package # hide from pause
Foo::DB::Workflow::Instance;
use Moose;
=pod
=head1 DESCRIPTION
This table will store workflow instances, retaining full history using this mechanism:
$parent_instance = $instance->prev;
It's structure is effectively close to an audit log.
If this is a problem then you need to use a different abstraction, look at
L<Class::Workflow::Util::Delta> and write a mutating storage solution instead,
where there is only one workflow instance per item instead of a full history.
It might be useful to add a cross reference from the workflow instance to the
item it is keeping state for, so that when you delete the item instead of
having a huge chain of cascaded deletes trigger through the C<prev> field, a
single, aggregate cascading delete
(C<DELETE FROM workflow_instance WHERE item = ?>) could be used instead.
=head1 COLUMNS
=over 4
=item state
The state the workflow instance is in. A rel to L<Foo::DB::Workflow::State>.
=item transition
The transition that created this workflow instance. Could be C<NULL> if this is
an initial state. A rel to L<Foo::DB::Workflow::Transition>.
=item prev
The instance this instance was derived from. Could be C<NULL> if this is an
initial state. A rel to this table.
=back
=head1 METHODS
=over 4
=item clone
This overrides L<Class::Workflow::Instance/clone> to use
L<DBIx::Class::Row/copy> instead of L<Class::MOP::Class/clone_object>.
=back
=cut
extends qw(DBIx::Class Moose::Object);
with qw(
Class::Workflow::Instance
);
__PACKAGE__->load_components(qw(PK::Auto Core));
__PACKAGE__->table("instance");
__PACKAGE__->add_columns(
id => {
data_type => "integer",
is_auto_increment => 1,
is_nullable => 0,
},
state => {
data_type => "integer",
is_nullable => 0,
},
transition => {
data_type => "integer",
is_nullable => 1,
},
( run in 0.867 second using v1.01-cache-2.11-cpan-140bd7fdf52 )