Workflow/Instance.pm

filter: Statementstmt 90.9% 20 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 88.8% 24 / 27 CC 2 SCAR 4.7
CC
2
Cov
91%
_clone
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.6
« Workflow/Transition/Validate.pm ↑ Summary Workflow/Context.pm »
1 #!/usr/bin/perl
2  
3 package Class::Workflow::Instance;
4 5 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 with 'MooseX::Clone';
7  
8 5 has prev => ( # the instance this instance was derived from
9 does => "Class::Workflow::Instance",
10 is => "ro",
11 required => 0,
12 );
13  
14 5 has transition => ( # the transition this instance is a result of
15 does => "Class::Workflow::Transition",
16 is => "ro",
17 required => 0,
18 );
19  
20 5 has state => ( # the state the instance is currently in
21 does => "Class::Workflow::State",
22 is => "ro",
23 required => 1,
24 );
25  
26 12 ▶sub derive {
Subroutine derive: called CC=1 SCAR=0.0
Pod documented
27 12 my ( $self, @fields ) = @_;
28 12 $self->clone( @fields, prev => $self );
29 }
30  
31 0 ▶sub _clone {
Subroutine _clone: not called CC=1 SCAR=6.9
32 0 my ( $self, @args ) = @_;
33 0 $self->clone(@args);
34 }
35  
36 # FIXME push this feature to MooseX::Clone by using special values ( \$MooseX::Clone::CLEAR or somesuch )
37 12 ▶around clone => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
38 12 my ( $next, $self, %fields ) = @_;
39  
40 12 my @clear = grep { not defined $fields{$_} } keys %fields;
41  
42 12 delete @fields{@clear};
43  
44 12 my $clone = $self->$next(%fields);
45  
46 12 my $meta = Class::MOP::get_metaclass_by_name(ref $self);
47  
48 12 foreach my $field ( @clear ) {
49 2 $meta->find_attribute_by_name($field)->clear_value($clone);
50 }
51  
52 12 return $clone;
53 5 };
54  
55 5 __PACKAGE__;
56  
57 __END__
« Workflow/Transition/Validate.pm ↑ Summary Workflow/Context.pm »