File Coverage

blib/lib/Rope/Autoload.pm
Criterion Covered Total %
statement 25 25 100.0
branch 5 8 62.5
condition 3 3 100.0
subroutine 7 8 87.5
pod n/a
total 40 44 90.9


line stmt bran cond sub pod time code
1             package Rope::Autoload;
2 29     29   12995 use strict;
  29         4197  
  29         2018  
3 29     29   179 use warnings;
  29         90  
  29         2118  
4 29     29   17570 use Want;
  29         70015  
  29         2583  
5 29     29   220 use Rope::Pro;
  29         52  
  29         1496  
6             my (%PRO);
7              
8             BEGIN {
9 29     29   182 %PRO = Rope::Pro->new;
10             }
11              
12             sub import {
13 33     33   344 my ($pkg, $caller) = (shift, scalar(caller));
14 33 50   0   453 $PRO{keyword}($caller, 'DESTROY', sub {}) unless ($caller->CORE::can('DESTROY'));
15             $PRO{keyword}($caller, 'AUTOLOAD', sub :lvalue {
16 204     204   26152 my $self = shift;
17 204         434 my $classname = ref $self;
18 204         394 my $validname = '[_a-zA-Z][\:a-zA-Z0-9_]*';
19 204         4099 our $AUTOLOAD =~ /^${classname}::($validname)$/;
20 204         639 my $key = $1;
21 204 50       588 die "illegal key name, must be of $validname form\n$AUTOLOAD" unless $key;
22 204 100 100     740 return $self->{$key}(@_) if !want(qw'LVALUE ASSIGN') && ref $self->{$key} eq 'CODE';
23 157 50       5053 $self->{$key} = $_[0] if defined $_[0];
24 157         451 return $self->{$key};
25 33         311 });
26             }
27              
28             1;
29              
30             =head1 NAME
31              
32             Rope::Autoload - Rope Autoload!
33              
34             =head1 VERSION
35              
36             Version 0.44
37              
38             =cut
39              
40             =head1 SYNOPSIS
41              
42             Quick summary of what the module does.
43              
44             Perhaps a little code snippet.
45              
46             package Knot;
47              
48             use Rope;
49             use Rope::Autoload;
50              
51             prototyped (
52             loops => 1,
53             hitches => 10,
54             ...
55              
56             );
57              
58             properties {
59             bends => {
60             type => sub { $_[0] =~ m/^\d+$/ ? $_[0] : die "$_[0] != integer" },
61             value => 10,
62             writeable => 0,
63             configurable => 1,
64             enumerable => 1,
65             },
66             ...
67             };
68              
69             function add_loops => sub {
70             my ($self, $loop) = @_;
71             $self->loops += $loop;
72             };
73              
74             1;
75              
76             ...
77              
78             my $k = Knot->new();
79              
80             say $k->loops; # 1;
81              
82             $k->add_loops(5);
83              
84             say $k->loops; # 6;
85              
86             $k->hitches = 15;
87            
88             $k->add_loops = 5; # errors
89              
90              
91             =head1 AUTHOR
92              
93             LNATION, C<< >>
94              
95             =head1 BUGS
96              
97             Please report any bugs or feature requests to C, or through
98             the web interface at L. I will be notified, and then you'll
99             automatically be notified of progress on your bug as I make changes.
100              
101             =head1 SUPPORT
102              
103             You can find documentation for this module with the perldoc command.
104              
105             perldoc Rope
106              
107             You can also look for information at:
108              
109             =over 4
110              
111             =item * RT: CPAN's request tracker (report bugs here)
112              
113             L
114              
115             =item * CPAN Ratings
116              
117             L
118              
119             =item * Search CPAN
120              
121             L
122              
123             =back
124              
125             =head1 ACKNOWLEDGEMENTS
126              
127             =head1 LICENSE AND COPYRIGHT
128              
129             This software is Copyright (c) 2023 by LNATION.
130              
131             This is free software, licensed under:
132              
133             The Artistic License 2.0 (GPL Compatible)
134              
135             =cut
136              
137             1; # End of Rope::Autoload