Symbolic/Custom/Base.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 27 / 27 CC 2 SCAR 2.9
CC
2
Cov
100%
aggregate_import
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Symbolic.pm ↑ Summary Symbolic/Custom.pm »
1  
2 =encoding utf8
3  
4 =head1 NAME
5  
6 Math::Symbolic::Custom::Base - Base class for tree tests and transformations
7  
8 =head1 SYNOPSIS
9  
10 # Extending the Math::Symbolic::Custom class:
11 package Math::Symbolic::Custom::MyTransformations;
12 use Math::Symbolic::Custom::Base;
13 BEGIN {*import = \&Math::Symbolic::Custom::Base::aggregate_import}
14
15 our $Aggregate_Export = [qw/apply_transformation1 .../];
16 sub apply_transformation1 {
17 # ...
18 }
19  
20 =head1 DESCRIPTION
21  
22 This is a base class for your extensions to the Math::Symbolic::Custom
23 class.
24  
25 To extend the class, just use the following template for your custom class:
26  
27 package Math::Symbolic::Custom::MyTransformations;
28  
29 use Math::Symbolic::Custom::Base;
30 BEGIN {*import = \&Math::Symbolic::Custom::Base::aggregate_import}
31
32 our $Aggregate_Export = [...]; # exported subroutines listed here.
33
34 # Now implement the subroutines.
35 # Exported subroutine names must start with 'apply_', 'mod_',
36 # 'is_', 'test_', 'contains_', or 'to_'
37
38 # ...
39
40 1;
41  
42 =head2 EXPORT
43  
44 Uses a custom exporter implementation to export certain routines from the
45 invoking namespace to the Math::Symbolic::Custom namespace.
46 But... Nevermind.
47  
48 =head1 SUBROUTINES
49  
50 =cut
51  
52 package Math::Symbolic::Custom::Base;
53  
54 23 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 23 our $VERSION = '0.613';
59 23 our $AUTOLOAD;
60  
61 =head2 aggregate_import
62  
63 aggregate_import() is the only public subroutine defined by
64 Math::Symbolic::Custom::Base and should only be called in BEGIN blocks like
65 the one shown in the SYNOPSIS above.
66  
67 =cut
68  
69 69 ▶sub aggregate_import {
Subroutine aggregate_import: called CC=2 SCAR=6.9
Pod documented
70 69 my $class = shift;
71 23 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
72 69 my $subs = ${"${class}::Aggregate_Export"};
73 69 foreach my $sub (@$subs) {
74 368 *{"Math::Symbolic::Custom::$sub"} = \&{"$class\:\:$sub"};
75 }
76 }
77  
78 23 1;
79 __END__
« Symbolic.pm ↑ Summary Symbolic/Custom.pm »