Persistent/Constraint.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 29 CC 1 SCAR 6.9
CC
1
Cov
0%
add_constraint
2.0
get_constraint
2.0
remove_constraint
2.0
CRAP 2.0
1 package Coat::Persistent::Constraint;
2  
3 use strict;
4 use warnings;
5  
6 # Singleton for storing constraints
7 my $REGISTRY = {};
8  
9 sub add_constraint {
10 my ($class, $constraint, $caller, $attribute, $value) = @_;
11 $REGISTRY->{$constraint}{$caller}{$attribute} = $value;
12 }
13  
14 sub get_constraint {
15 my ($class, $constraint, $caller, $attribute) = @_;
16 $REGISTRY->{$constraint}{$caller}{$attribute} || 0;
17 }
18  
19 sub remove_constraint {
20 my ($class, $constraint, $caller, $attribute) = @_;
21 delete $REGISTRY->{$constraint}{$caller}{$attribute};
22 }
23  
24 sub list_constraints {
25 my ($class, $constraint, $caller) = @_;
26 keys %{ $REGISTRY->{$constraint}{$caller} };
27 }
28  
29 1;