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   48828 use warnings;
  2         5  
  2         63  
4 2     2   11 use strict;
  2         4  
  2         60  
5              
6 2     2   1853 use Attribute::Handlers;
  2         333577  
  2         16  
7              
8 2     2   2080 use namespace::clean ();
  2         55130  
  2         48  
9 2     2   20 use B::Hooks::EndOfScope;
  2         4  
  2         11  
10 2     2   1740 use Sub::Identify qw(:all);
  2         2067  
  2         551  
11              
12              
13             =head1 NAME
14              
15             Sub::Private - Private subroutines and methods
16              
17             =head1 VERSION
18              
19             Version 0.01
20              
21             =cut
22              
23             our $VERSION = '0.01';
24              
25             =head1 SYNOPSIS
26              
27             package Foo;
28             use Sub::Private;
29              
30             sub foo :Private {
31             return 42;
32             }
33              
34             sub bar {
35             return foo() + 1;
36             }
37              
38             =cut
39              
40             sub UNIVERSAL::Private :ATTR(CODE,BEGIN,CHECK) {
41 2     2 0 1045 my ($package, $symbol, $referent, $attr, $data) = @_;
42              
43             on_scope_end {
44 1     1   193 namespace::clean->clean_subroutines(
45             stash_name( $referent ),
46             sub_name( $referent )
47             );
48             }
49 2     2   14 }
  2         5  
  2         17  
  2         15  
50              
51             =head1 DESCRIPTION
52              
53             This module provide a C<:Private> attribute for subroutines. By using the
54             attribut you get truly private methods.
55              
56              
57             =head1 AUTHOR
58              
59             Peter Makholm, 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              
68             =head1 SEE ALSO
69              
70             namespace::clean
71              
72             =head1 SUPPORT
73              
74             You can find documentation for this module with the perldoc command.
75              
76             perldoc Sub::Private
77              
78              
79             You can also look for information at:
80              
81             =over 4
82              
83             =item * RT: CPAN's request tracker
84              
85             L
86              
87             =item * AnnoCPAN: Annotated CPAN documentation
88              
89             L
90              
91             =item * CPAN Ratings
92              
93             L
94              
95             =item * Search CPAN
96              
97             L
98              
99             =back
100              
101              
102             =head1 ACKNOWLEDGEMENTS
103              
104              
105             =head1 COPYRIGHT & LICENSE
106              
107             Copyright 2009 Peter Makholm, all rights reserved.
108              
109             This program is free software; you can redistribute it and/or modify it
110             under the same terms as Perl itself.
111              
112              
113             =cut
114              
115             1; # End of Sub::Private