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 3     3   707888 use warnings;
  3         6  
  3         277  
4 3     3   15 use strict;
  3         5  
  3         82  
5              
6 3     3   1952 use Attribute::Handlers;
  3         19770  
  3         17  
7              
8 3     3   1759 use namespace::clean qw();
  3         55330  
  3         132  
9 3     3   23 use B::Hooks::EndOfScope qw(on_scope_end);
  3         6  
  3         22  
10 3     3   1747 use Sub::Identify qw(get_code_info);
  3         3587  
  3         396  
11              
12             =head1 NAME
13              
14             Sub::Private - Private subroutines and methods
15              
16             =head1 VERSION
17              
18             Version 0.04
19              
20             =cut
21              
22             our $VERSION = '0.04';
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 170 my ($package, $symbol, $referent, $attr, $data) = @_;
41              
42             on_scope_end {
43 1     1   170 namespace::clean->clean_subroutines( get_code_info( $referent ) );
44             }
45 3     3   22 }
  3         7  
  3         27  
  1         5  
46              
47             =head1 DESCRIPTION
48              
49             This module provide a C<:Private> attribute for subroutines.
50             By using the attribute you get truly private methods.
51              
52             =head1 AUTHOR
53              
54             Original Author:
55             Peter Makholm, C<< >>
56              
57             Current maintainer:
58             Nigel Horne, C<< >>
59              
60             =head1 BUGS
61              
62             Please report any bugs or feature requests to C, or through
63             the web interface at L. I will be notified, and then you'll
64             automatically be notified of progress on your bug as I make changes.
65              
66             =head1 SEE ALSO
67              
68             L
69              
70             =head1 SUPPORT
71              
72             You can find documentation for this module with the perldoc command.
73              
74             perldoc Sub::Private
75              
76             You can also look for information at:
77              
78             =over 4
79              
80             =item * RT: CPAN's request tracker
81              
82             L
83              
84             =item * Search CPAN
85              
86             L
87              
88             =back
89              
90             =head1 ACKNOWLEDGEMENTS
91              
92             =head1 COPYRIGHT & LICENSE
93              
94             Copyright 2009 Peter Makholm, all rights reserved.
95              
96             This program is free software; you can redistribute it and/or modify it
97             under the same terms as Perl itself.
98              
99             =cut
100              
101             1; # End of Sub::Private