| 1 | 33 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 33 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 33 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 33 | ▶ | use VS::RuleEngine::Engine::Common; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 33 | ▶ | use VS::RuleEngine::TypeDecl; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 67 | ▶ | sub add_rule { | ||||||||
|
Subroutine
add_rule: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 10 | 67 | my ($self, $name, $rule, $defaults, @args) = @_; | |||||||||
| 11 | 67 | $self->_check_add_args('Rule', \&has_rule, $name, $rule); | |||||||||
| 12 | 58 | $self->_rules->set($name => VS::RuleEngine::TypeDecl->new($rule, $defaults, @args)); | |||||||||
| 13 | 58 | $self->_rule_actions->set($name => []); | |||||||||
| 14 | 58 | push @{$self->_rule_order}, $name; | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 49 | ▶ | sub add_rule_action { | ||||||||
|
Subroutine
add_rule_action: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | 49 | my ($self, $name, $action) = @_; | |||||||||
| 19 | |||||||||||
| 20 | 49 | my $actions = $self->_get_rule_actions($name); | |||||||||
| 21 | 48 | push @$actions, $action; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | sub rules { | ||||||||
|
Subroutine
rules: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 25 | 1 | my $self = shift; | |||||||||
| 26 | 1 | return $self->_rules->keys; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 264 | ▶ | sub has_rule { | ||||||||
|
Subroutine
has_rule: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 30 | 264 | my ($self, $name) = @_; | |||||||||
| 31 | 264 | return $self->_rules->exists($name); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 54 | ▶ | sub _get_rule { | ||||||||
|
Subroutine
_get_rule: called CC=2 SCAR=6.9
| |||||||||||
| 35 | 54 | my ($self, $name) = @_; | |||||||||
| 36 | |||||||||||
| 37 | 54 | ▶ | if ($self->has_rule($name)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 53 | return $self->_rules->get($name); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 1 | croak "Rule '${name}' does not exist"; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 99 | ▶ | sub _get_rule_actions { | ||||||||
|
Subroutine
_get_rule_actions: called CC=2 SCAR=6.9
| |||||||||||
| 45 | 99 | my ($self, $name) = @_; | |||||||||
| 46 | |||||||||||
| 47 | 99 | ▶ | if ($self->has_rule($name)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 98 | return $self->_rule_actions->get($name); | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | croak "Rule '${name}' does not exist"; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 1 | ▶ | sub set_rule_order { | ||||||||
|
Subroutine
set_rule_order: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 55 | 1 | my ($self, @order) = @_; | |||||||||
| 56 | |||||||||||
| 57 | 1 | $self->{_rule_order} = \@order; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 2 | ▶ | sub rule_order { | ||||||||
|
Subroutine
rule_order: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 61 | 2 | my $self = shift; | |||||||||
| 62 | 2 | return @{$self->_rule_order}; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 33 | 1; | |||||||||
| 66 | __END__ | ||||||||||