MooseX::Meta::Attribute::Lvalue - Immplements lvalue attributes via meta-attribute trait
package App; use Moose; with 'MooseX::Meta::Attribute::Lvalue'; has 'name' => ( is => 'rw' , isa => 'Str' , required => 1 , traits => [ 'Lvalue' ] , # REQUIRED ); package main; my $app = App->new( name => 'Foo' ); $app->name = "Bar"; print $app->name; # Bar
WARNING: This module provides syntactic sugar at the expense of some Moose's encapsulation. The Moose framework does not support type checking of Lvalue attributes. You should only use this role when the convenience of the Lvalue attributes outweighs the need to type checking.
This package provides a Moose meta attribute via a role/trait that provides Lvalue accessors to your Moose attributes. Which means that instead of writing:
$myclass->name( "Foo" );
You can use the more functional and natural appearing:
$myclass->name = "Foo";
For details of Lvalue implementation in Perl, please see: http://perldoc.perl.org/perlsub.html#Lvalue-subroutines
This method does the work of installing lvalue writers for attributes that are: 1) read-write 2) the attribute does MooseX::Meta::Attribute::Trait::Lvalue
This is a dummy sub that does nothing. It allows the method modifier 'after BUILD' which installs the lvalue writer subs.
None by default.
<cbrown at opendatagroup.com>
Please report any bugs or feature requests to
bug-moosex-attribute-lvalue at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Attribute-Lvalue. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Copyright 2008 Christopher Brown, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.