Hello nysus,

It looks like you can't have with "Foo"; in your class and handles "Foo"; in an attribute at the same time, which is quite natural - you either impersonate a role, or point to someone else performing it for you. You have to choose.

I'm new to Moose, though. Take my advice with a grain of salt.

Hope that helps.

UPD: a minimal example

==> doo.pl <== #!/usr/bin/env perl use strict; use warnings; use Foo; print Foo->new->bar, "\n"; ==> Foo.pm <== package Foo; use Moose; with "Roo"; use Goo; has goo => is => "rw", isa => "Roo", handles => "Roo" , default => sub { Goo->new; }; 1; ==> Goo.pm <== package Goo; use Moose; with "Roo"; 1; ==> Roo.pm <== package Roo; use Moose::Role; sub bar { 42 }; 1;

This doesn't work. One needs to comment out either "with", or "handles" in Foo.pm for the perl -I. doo.pl to output 42 correctly.


In reply to Re: Delegating to a role in Moose by Dallaylaen
in thread Delegating to a role in Moose by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.