File Coverage

blib/lib/Pad/Tie/Plugin/ScalarAttr.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 2 50.0
total 31 32 96.8


line stmt bran cond sub pod time code
1 1     1   420 use strict;
  1         1  
  1         21  
2 1     1   2 use warnings;
  1         1  
  1         25  
3              
4             package Pad::Tie::Plugin::ScalarAttr;
5              
6 1     1   3 use Devel::LexAlias ();
  1         1  
  1         12  
7 1     1   2 use base 'Pad::Tie::Plugin';
  1         1  
  1         190  
8              
9 1     1 1 2 sub provides { 'scalar_attr' }
10              
11             sub scalar_attr {
12 1     1 0 2 my ($plugin, $ctx, $self, $args) = @_;
13              
14 1         3 $args = $plugin->canon_args($args);
15              
16 1         2 my $rv = { pre_call => [] };
17 1         2 for my $method (keys %$args) {
18 1         1 my $name = $args->{$method};
19 1         3 push @{ $rv->{pre_call} }, sub {
20 6     6   6 my ($self, $code, $args) = @_;
21             Devel::LexAlias::lexalias(
22             $code,
23             '$' . $name,
24 6         20 \$self->{invocant}->{$method},
25             );
26 1         1 };
27             }
28              
29 1         3 return $rv;
30             }
31              
32             1;