File Coverage

blib/lib/Aspect/Modular.pm
Criterion Covered Total %
statement 28 32 87.5
branch 4 6 66.6
condition 0 3 0.0
subroutine 8 9 88.8
pod 0 3 0.0
total 40 53 75.4


line stmt bran cond sub pod time code
1             package Aspect::Modular;
2              
3 4     4   18 use strict;
  4         8  
  4         112  
4 4     4   15 use warnings;
  4         9  
  4         97  
5 4     4   1167 use Aspect::Library ();
  4         7  
  4         1099  
6              
7             our $VERSION = '0.97_06';
8             our @ISA = 'Aspect::Library';
9              
10             sub new {
11 7     7 0 15 my $class = shift;
12 7         34 my $self = bless { @_ }, $class;
13              
14             # Generate the appropriate advice
15             $self->{advice} = [
16 7         55 $self->get_advice( $self->args )
17             ];
18              
19             # Warn if the aspect is supposed to be permanent,
20             # but the advice isn't created as permanent.
21 7 100       86 if ( $self->lexical ) {
22 3 50       7 if ( grep { not $_->lexical } @{$self->{advice}} ) {
  3         29  
  3         10  
23 0         0 warn("$class creates lexical advice for global aspects");
24             }
25             } else {
26 4 50       8 if ( grep { $_->lexical } @{$self->{advice}} ) {
  4         36  
  4         13  
27 0         0 warn("$class creates global advice for lexical aspects");
28             }
29             }
30              
31 7         63 return $self;
32             }
33              
34             sub args {
35 7     7 0 11 @{$_[0]->{args}};
  7         47  
36             }
37              
38             sub lexical {
39             $_[0]->{lexical};
40             }
41              
42             sub get_advice {
43 0   0 0 0   my $class = ref $_[0] || $_[0];
44 0           die("Method 'get_advice' is not implemented by class '$class'");
45             }
46              
47              
48              
49              
50              
51             ######################################################################
52             # Back Compatibility
53              
54             BEGIN {
55 4     4   120 *params = *args;
56             }
57              
58              
59              
60              
61              
62             ######################################################################
63             # Optional XS Acceleration
64              
65             BEGIN {
66 4     4   8 local $@;
67 4     4   333 eval <<'END_PERL';
  4         22  
  4         106  
  4         38  
68             use Class::XSAccessor 1.08 {
69             replace => 1,
70             getters => {
71             'lexical' => 'lexical',
72             },
73             };
74             END_PERL
75             }
76              
77             1;
78              
79             __END__