line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::Plugin::LvalueAttributes::Interp; |
2
|
|
|
|
|
|
|
$Mason::Plugin::LvalueAttributes::Interp::VERSION = '2.24'; |
3
|
1
|
|
|
1
|
|
638
|
use Mason::PluginRole; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
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
|
1
|
|
|
1
|
|
2
|
my ( $self, $class ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
7
|
my @attrs = $class->meta->get_all_attributes(); |
14
|
1
|
|
|
|
|
79
|
foreach my $attr (@attrs) { |
15
|
4
|
100
|
|
|
|
188
|
if ( $attr->_is_metadata eq 'rw' ) { |
16
|
1
|
|
|
|
|
13
|
my $name = $attr->name; |
17
|
|
|
|
|
|
|
$class->meta->add_method( |
18
|
|
|
|
|
|
|
$name, |
19
|
|
|
|
|
|
|
sub : lvalue { |
20
|
4
|
100
|
|
4
|
|
13
|
if ( defined( $_[1] ) ) { |
21
|
1
|
|
|
|
|
2
|
$_[0]->{$name} = $_[1]; |
22
|
|
|
|
|
|
|
} |
23
|
4
|
|
|
|
|
23
|
$_[0]->{$name}; |
24
|
|
|
|
|
|
|
} |
25
|
1
|
|
|
|
|
5
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |