MooseX::CurriedHandles - Delegate methods to member objects, curried with more methods!
Version 0.03
package MyClass; use Moose; use MooseX::CurriedHandles; has foo => ( isa => 'Str', is => 'ro', required => 0, ); has delegate => ( isa => 'Foo', metaclass => 'MooseX::CurriedHandles', is => 'ro', default => sub { Foo->new }, required => 0, lazy => 1, curried_handles => { 'bar' => { 'blah' => [ sub { $_[0]->foo }, ], }, }, );
This is the module formerly known as MooseX::DeepAccessors. This is a much better and more Moose-consistent name for it.
MooseX::DeepAccessors
The curried_handles attribute takes parameters in the form:
curried_handles
curried_handles => { 'LOCALMETHOD' => { 'DELEGATEMETHOD' => [ sub { $_[0]->OTHERLOCALMETHOD } ] } }
Where LOCALMETHOD is the method on this class to create, DELEGATEMETHOD is the method on the object whose accessor is being described, and OTHERLOCALMETHOD is a method on this class, which will be called with the object passed to LOCALMETHOD and whose return value will be passed to DELEGATEMETHOD.
LOCALMETHOD
DELEGATEMETHOD
OTHERLOCALMETHOD
To put it another way, it allows you to write: $object->localmethod;
Rather than: $object->delegate->delegatemethod( $object->otherlocalmethod );
Any extra arguments passed to localmethod will be passed to the delegatemethod:
localmethod
delegatemethod
$object->localmethod(@foo)
is equivalent to:
$object->delegate->delegatemethod( $object->anotherlocalmethod, @foo );
And thus can be thought of as providing another kind of currying for Moose methods.
Joel Bernstein, <rataxis at cpan.org>
<rataxis at cpan.org>
Please report any bugs or feature requests to bug-moosex-curriedhandles at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-CurriedHandles. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-moosex-curriedhandles at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc MooseX::CurriedHandles
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-CurriedHandles
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/MooseX-CurriedHandles
CPAN Ratings
http://cpanratings.perl.org/d/MooseX-CurriedHandles
Search CPAN
http://search.cpan.org/dist/MooseX-CurriedHandles
This module was written to scratch an itch I had, but the actual code idea comes from t0m and the impetus to release it from nothingmuch. So thankyou, #moose.
t0m
nothingmuch
#moose
Really, this shouldn't be necessary, and hopefully the next Moose release will integrate this functionality making this module redundant.
Thanks to t0m and autarch for suggesting a better name.
autarch
(C) Copyright 2008 Joel Bernstein, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MooseX::CurriedHandles, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::CurriedHandles
CPAN shell
perl -MCPAN -e shell install MooseX::CurriedHandles
For more information on module installation, please visit the detailed CPAN module installation guide.