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