File Coverage

lib/Workflow/Condition/Negated.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 22 22 100.0


line stmt bran cond sub pod time code
1              
2             use strict;
3 20     20   117 use warnings;
  20         67  
  20         580  
4 20     20   94  
  20         37  
  20         927  
5             our $VERSION = '1.61';
6              
7             use base qw( Workflow::Condition );
8 20     20   124  
  20         50  
  20         4505  
9             my @FIELDS = qw( name class negated );
10             __PACKAGE__->mk_accessors(@FIELDS);
11              
12             my ( $self, $params ) = @_;
13             my $negated = $params->{name};
14 13     13   22 $negated =~ s/ \A ! //gx;
15 13         18 $self->negated( $negated );
16 13         43 $self->SUPER::_init($params);
17 13         34 }
18 13         127  
19             my ($self, $wf) = @_;
20             return not $self->evaluate_condition($wf, $self->negated);
21             }
22 43     43 1 73  
23 43         99  
24             1;
25              
26              
27             =pod
28              
29             =head1 NAME
30              
31             Workflow::Condition::Negated - Negate workflow condition result
32              
33             =head1 VERSION
34              
35             This documentation describes version 1.61 of this package
36              
37             =head1 DESCRIPTION
38              
39             This class is used by C<Workflow::State> to handle I<negated conditions>:
40             conditions of which the referring name starts with an exclamation mark (!).
41              
42             Such conditions refer to another condition (by the name after the '!') and
43             return the negated result of the condition referred to (true becomes false
44             while false becomes true).
45              
46             =head1 SYNOPSIS
47              
48             In condition.xml:
49              
50             <condition name="check_approvals" class="...">
51             </condition>
52              
53             In workflow.xml:
54              
55             <state name="CHECK_APPROVALS" autorun="yes">
56             <action name="null_1" resulting_state="APPROVED">
57             <condition name="check_approvals" />
58             </action>
59             <action name="null_2" resulting_state="REJECTED">
60             <condition name="!check_approvals" />
61             </action>
62             </state>
63              
64             =cut
65              
66             =head1 AUTHORS
67              
68             See L<Workflow>
69              
70             =head1 COPYRIGHT
71              
72             Copyright (c) 2004-2022 Chris Winters. All rights reserved.
73              
74             This library is free software; you can redistribute it and/or modify
75             it under the same terms as Perl itself.
76              
77             Please see the F<LICENSE>
78              
79             =head1 AUTHORS
80              
81             Please see L<Workflow>
82              
83             =cut