[Israel.pm] Delegation in Moose and Other Delegation Modules
Shlomi Fish
shlomif at iglu.org.il
Sat Jul 21 06:12:43 PDT 2007
Hi all!
We discussed delegation in Perl and other languages here before:
http://perl.org.il/pipermail/perl/2007-January/thread.html#8390
As I discovered Moose has a delagation mechanism called "handles":
http://cpan.uwinnipeg.ca/htdocs/Moose/Moose.html#i_handles_gt_ARRAY_HASH_REGEXP_ROLE_
You can pass to an accessor an array of method names and it will install
delegates for each one. Or you can pass a hash ref and it will map from
locally-installed names to the original names.
What I did for this in my code is:
<<<<<<<<
handles =>
{
map { '_'.$_ => $_ }
qw(curr_line next_line with_curr_line)
},
>>>>>>>>
After more investigation, I also found more modules for delegation on CPAN.
Like:
http://cpan.uwinnipeg.ca/htdocs/Class-Delegator/Class/Delegator.html
See also:
http://cpan.uwinnipeg.ca/htdocs/Class-Delegator/Class/Delegator.html#see_also
Regards,
Shlomi Fish
---------------------------------------------------------------------
Shlomi Fish shlomif at iglu.org.il
Homepage: http://www.shlomifish.org/
If it's not in my E-mail it doesn't happen. And if my E-mail is saying
one thing, and everything else says something else - E-mail will conquer.
-- An Israeli Linuxer
More information about the Perl
mailing list