http://qs1969.pair.com?node_id=737084

rodd has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,
Desperatly need some Moose enlightment here.

I'm trying to find a away to create a curry style class called BodyParts using Moose. I want to use my class like this:

package main; use BodyParts; my $body = BodyParts->new; $body = $body->legs( size=>42 )->eyes( color => blue); print $body->eyes->color; ## blue

Basically my problem comes down to:

  • I don't want to write a lot of subclasses, just a single moosed up package in BodyParts.pm.
  • Every accessor should return $self
  • But I don't want to write around directives for every accessor I create just to return $self.

    Is there a MooseX extension that takes care of that? What's the true path to concise code here?
    Thanks for your enlightment,
    -rodrigo