File Coverage

blib/lib/Mason/Plugin/LvalueAttributes.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Mason::Plugin::LvalueAttributes;
2             $Mason::Plugin::LvalueAttributes::VERSION = '2.23';
3 1     1   551 use Moose;
  1         1  
  1         5  
4             with 'Mason::Plugin';
5              
6             __PACKAGE__->meta->make_immutable();
7              
8             1;
9              
10             __END__
11              
12             =pod
13              
14             =head1 NAME
15              
16             Mason::Plugin::LvalueAttributes - Create lvalue accessors for all rw component
17             attributes
18              
19             =head1 SYNOPSIS
20              
21             <%class>
22             has 'a' => (is => "rw")
23             has 'b' => (is => "ro")
24             </%class>
25              
26             <%init>
27             # set a to 5
28             $.a = 5;
29              
30             # set a to 6
31             $.a(6);
32              
33             # error
34             $.b = 7;
35             </%init>
36              
37             =head1 DESCRIPTION
38              
39             This plugins creates an Lvalue accessor for every read/write attribute in the
40             component. Which means that instead of writing:
41              
42             $.name( "Foo" );
43              
44             you can use the more natural syntax
45              
46             $.name = "Foo";
47              
48             =head1 WARNING
49              
50             Standard Moose setter features such as type checking, triggers, and coercion
51             will not work on Lvalue attributes. You should only use this plugin when the
52             convenience of the Lvalue attributes outweighs the need for setter features.
53              
54             =head1 ACKNOWLEDGEMENTS
55              
56             Inspired by Christopher Brown's
57             L<MooseX::Meta::Attribute::Lvalue|MooseX::Meta::Attribute::Lvalue >.
58              
59             =head1 SEE ALSO
60              
61             L<Mason|Mason>
62              
63             =head1 AUTHOR
64              
65             Jonathan Swartz <swartz@pobox.com>
66              
67             =head1 COPYRIGHT AND LICENSE
68              
69             This software is copyright (c) 2012 by Jonathan Swartz.
70              
71             This is free software; you can redistribute it and/or modify it under
72             the same terms as the Perl 5 programming language system itself.
73              
74             =cut