File Coverage

blib/lib/Class/Accessor/Tiny.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 21 22 95.4


line stmt bran cond sub pod time code
1             package Class::Accessor::Tiny;
2             our $VERSION = '0.10';
3 1     1 0 2021 sub new{ return bless {}, $_[0] };
4             sub import{
5 3     3   659 my $self = shift;
6 3         6 my $caller = caller;
7 3         16 for my $name ( @_ ){
8 2 100       9 if ( $name eq 'new' ){
9 1         13 *{ $caller . "::new" } = \&new;
  1         14  
10             }
11             else {
12 1     1   5 my $setter = sub { $_[0]->{$name} = $_[1],$_[0] };
  1         9  
13 1     2   4 my $gettter = sub { $_[0]->{$name} };
  2         16  
14 1         2 *{ $caller . "::get_$name" } = $gettter;
  1         6  
15 1         2 *{ $caller . "::set_$name" } = $setter;
  1         14  
16             }
17             }
18             }
19             1;
20             __END__