blib/lib/Mason/Plugin/LvalueAttributes/Interp.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 23 SCAR 24.8
CC
3
Cov
0%
_add_lvalue_attribute_methods
12.0
BEGIN
2.0
CRAP 12.0
1 package Mason::Plugin::LvalueAttributes::Interp;
2 $Mason::Plugin::LvalueAttributes::Interp::VERSION = '2.23';
3 use Mason::PluginRole;
4  
5 after 'modify_loaded_class' => sub {
6 my ( $self, $compc ) = @_;
7 $self->_add_lvalue_attribute_methods($compc);
8 };
9  
10 sub _add_lvalue_attribute_methods {
11 my ( $self, $class ) = @_;
12  
13 my @attrs = $class->meta->get_all_attributes();
14 foreach my $attr (@attrs) {
15 if ( $attr->_is_metadata eq 'rw' ) {
16 my $name = $attr->name;
17 $class->meta->add_method(
18 $name,
19 sub : lvalue {
20 if ( defined( $_[1] ) ) {
21 $_[0]->{$name} = $_[1];
22 }
23 $_[0]->{$name};
24 }
25 );
26 }
27 }
28 }
29  
30 1;