File Coverage

blib/lib/App/revealup/base.pm
Criterion Covered Total %
statement 34 34 100.0
branch 9 10 90.0
condition n/a
subroutine 9 9 100.0
pod 0 1 0.0
total 52 54 96.3


line stmt bran cond sub pod time code
1             package App::revealup::base;
2 7     7   73699 use strict;
  7         23  
  7         197  
3 7     7   52 use warnings;
  7         13  
  7         292  
4              
5             sub import {
6 18     18   68 my $caller = caller(0);
7 7     7   48 no strict 'refs';
  7         21  
  7         1425  
8 18     59   83 *{"${caller}::has"} = sub { attr($caller, @_) };
  18         107  
  59         142  
9 18         69 *{"${caller}::new"} = sub {
10 14     14   8487 my ($klass, %opt) = @_;
11 14         64 for my $key (keys %opt) {
12 10 100       37 attr($caller, $key, $opt{$key}) if $opt{$key};
13             }
14 14         52 return bless \%opt, $klass;
15 18         72 };
16 18         113 strict->import;
17 18         919 warnings->import;
18             }
19              
20             sub attr {
21 64     64 0 155 my ( $caller, $k, $v ) = @_;
22 7     7   50 no strict 'refs';
  7         13  
  7         935  
23 64 100       83 return if defined *{"${caller}::$k"};
  64         390  
24 60         349 *{"${caller}::$k"} = sub {
25 64     64   951 my ( $self, $value ) = @_;
26 64 100       151 if ( !$value ) {
27 61 100       199 $self->{$k} = $v if !$self->{$k};
28 61         272 return $self->{$k};
29             }
30 3 50       28 $self->{$k} = $value if $value;
31 60         205 };
32             }
33              
34             1;