File Coverage

blib/lib/Sub/Private.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 33 34 97.0


line stmt bran cond sub pod time code
1             package Sub::Private;
2              
3 2     2   138774 use warnings;
  2         13  
  2         66  
4 2     2   11 use strict;
  2         4  
  2         39  
5              
6 2     2   1109 use Attribute::Handlers;
  2         10161  
  2         10  
7              
8 2     2   1120 use namespace::clean qw();
  2         31614  
  2         50  
9 2     2   14 use B::Hooks::EndOfScope qw(on_scope_end);
  2         4  
  2         13  
10 2     2   1035 use Sub::Identify qw(get_code_info);
  2         1965  
  2         331  
11              
12             =head1 NAME
13              
14             Sub::Private - Private subroutines and methods
15              
16             =head1 VERSION
17              
18             Version 0.02
19              
20             =cut
21              
22             our $VERSION = '0.02';
23              
24             =head1 SYNOPSIS
25              
26             package Foo;
27             use Sub::Private;
28              
29             sub foo :Private {
30             return 42;
31             }
32              
33             sub bar {
34             return foo() + 1;
35             }
36              
37             =cut
38              
39             sub UNIVERSAL::Private :ATTR(CODE,BEGIN) {
40 1     1 0 220 my ($package, $symbol, $referent, $attr, $data) = @_;
41              
42             on_scope_end {
43 1     1   150 namespace::clean->clean_subroutines( get_code_info( $referent ) );
44             }
45 2     2   15 }
  2         4  
  2         15  
  1         7  
46              
47             =head1 DESCRIPTION
48              
49             This module provide a C<:Private> attribute for subroutines. By using the
50             attribut you get truly private methods.
51              
52              
53             =head1 AUTHOR
54              
55             Peter Makholm, C<< >>
56              
57             =head1 MAINTAINER
58              
59             Nigel Horne, C<< >>
60              
61             =head1 BUGS
62              
63             Please report any bugs or feature requests to C, or through
64             the web interface at L. I will be notified, and then you'll
65             automatically be notified of progress on your bug as I make changes.
66              
67             =head1 SEE ALSO
68              
69             namespace::clean
70              
71             =head1 SUPPORT
72              
73             You can find documentation for this module with the perldoc command.
74              
75             perldoc Sub::Private
76              
77              
78             You can also look for information at:
79              
80             =over 4
81              
82             =item * RT: CPAN's request tracker
83              
84             L
85              
86             =item * AnnoCPAN: Annotated CPAN documentation
87              
88             L
89              
90             =item * CPAN Ratings
91              
92             L
93              
94             =item * Search CPAN
95              
96             L
97              
98             =back
99              
100              
101             =head1 ACKNOWLEDGEMENTS
102              
103              
104             =head1 COPYRIGHT & LICENSE
105              
106             Copyright 2009 Peter Makholm, all rights reserved.
107              
108             This program is free software; you can redistribute it and/or modify it
109             under the same terms as Perl itself.
110              
111             =cut
112              
113             1; # End of Sub::Private