![]() |
![]()
| ![]() |
![]()
NAMELvalue - add lvalue getters and setters to existing objects VERSIONversion 0.21 SYNOPSISLvalue takes an object produced by some other package and wraps it with lvalue functionality implemented with the object's original getter and setter routines. Lvalue assumes its object uses the relatively standard getter / setter idiom where any arguments is a setter, and no arguments is a getter. By wrapping an existing object's getters and setters, Lvalue gives you the syntactic niceties of lvalues, without the inherent encapsulation violations of the :lvalue subroutine attribute. my $obj = NormalObject->new(); $obj->value(5); print $obj->value(); # prints 5 use Lvalue; Lvalue->wrap( $obj ); $obj->value = 10; print $obj->value; # prints 10 $_ += 2 for $obj->value; print $obj->value; # prints 12 EXPORTthis module does not export anything by default but can export the functions below (which can all also be called as methods of Lvalue) use Lvalue qw/lvalue/; # or 'wrap', also 'unwrap'/'rvalue' lvalue my $obj = SomePackage->new; $obj->value = 5; Lvalue->unwrap( $obj ); $obj->value = 6; # dies FUNCTIONS
AUTHOREric Strom, "<asg at cpan.org>" BUGSspecial care is taken to ensure that overloaded objects still work properly. if you encounter an error please let me know. Please report any bugs or feature requests to "bug-lvalue at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lvalue>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. COPYRIGHT & LICENSECopyright 2010 Eric Strom. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information.
|