line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
178
|
use 5.008; |
|
10
|
|
|
|
|
38
|
|
|
10
|
|
|
|
|
460
|
|
2
|
10
|
|
|
10
|
|
61
|
use strict; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
298
|
|
3
|
10
|
|
|
10
|
|
63
|
use warnings; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
462
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Hook::Modular::Rules; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
10
|
|
|
10
|
|
207
|
$Hook::Modular::Rules::VERSION = '1.101050'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Workflow rules |
10
|
10
|
|
|
10
|
|
6638
|
use Hook::Modular::Operator; |
|
10
|
|
|
|
|
37
|
|
|
10
|
|
|
|
|
121
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
6
|
|
|
6
|
1
|
18
|
my ($class, $op, @rules) = @_; |
14
|
6
|
50
|
|
|
|
37
|
Hook::Modular::Operator->is_valid_op(uc($op)) |
15
|
|
|
|
|
|
|
or Hook::Modular->context->error("operator $op not supported"); |
16
|
6
|
|
|
|
|
43
|
bless { |
17
|
|
|
|
|
|
|
op => uc($op), |
18
|
|
|
|
|
|
|
rules => [ map Hook::Modular::Rule->new($_), @rules ], |
19
|
|
|
|
|
|
|
}, $class; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub dispatch { |
23
|
8
|
|
|
8
|
1
|
18
|
my ($self, $plugin, $hook, $args) = @_; |
24
|
8
|
50
|
|
|
|
35
|
return 1 unless $plugin->dispatch_rule_on($hook); |
25
|
8
|
|
|
|
|
76
|
my @bool; |
26
|
8
|
|
|
|
|
11
|
for my $rule (@{ $self->{rules} }) { |
|
8
|
|
|
|
|
32
|
|
27
|
8
|
100
|
|
|
|
27
|
push @bool, ($rule->dispatch($args) ? 1 : 0); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# can't find rules for this phase: execute it |
31
|
8
|
50
|
|
|
|
65
|
return 1 unless @bool; |
32
|
8
|
|
|
|
|
43
|
Hook::Modular::Operator->call($self->{op}, @bool); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub id { |
36
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
37
|
0
|
|
|
|
|
|
join '|', map $_->id, @{ $self->{rules} }; |
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub as_title { |
41
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
join " $self->{op} ", map $_->as_title, @{ $self->{rules} }; |
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |