line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VS::RuleEngine::Action::SetGlobal; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
767
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use VS::RuleEngine::Constants; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base qw(VS::RuleEngine::Action); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
206
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
1
|
4
|
my ($pkg, %args) = @_; |
14
|
1
|
|
|
|
|
4
|
my $self = bless \%args, $pkg; |
15
|
1
|
|
|
|
|
4
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub perform { |
19
|
1
|
|
|
1
|
1
|
3
|
my ($self, $global) = @_[KV_SELF, KV_GLOBAL]; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
11
|
while (my ($k, $v) = each %$self) { |
22
|
2
|
|
|
|
|
7
|
$global->set($k => $v); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
VS::RuleEngine::Action::SetGlobal - Generic action to set key/value pairs in the global object |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use VS::RuleEngine::Declare; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $engine = engine { |
38
|
|
|
|
|
|
|
# input_1 and input_2 will be set to the global object (KV_GLOBAL) |
39
|
|
|
|
|
|
|
# every time this action is invoked |
40
|
|
|
|
|
|
|
action 'set_properties' => instanceof "VS::RuleEngine::Action::SetGlobal" => with_args { |
41
|
|
|
|
|
|
|
'input_1' => 5, |
42
|
|
|
|
|
|
|
'input_2' => -5, |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 DESCRIPTION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This is a generic action that sets key/value pairs to the global object. Any |
49
|
|
|
|
|
|
|
existing value for a given key will be overwritten. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 USAGE |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 Rule arguments |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This rule expects a hash as its argument, which is what C<< with_args >> provides, |
56
|
|
|
|
|
|
|
where the key is the name of the key to set and the value is its value. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=begin PRIVATE |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over 4 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item new |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item perform |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=end PRIVATE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SEE ALSO |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |