Hi nysus,
the intention of
handles => 'Some::Role',
is that Some::Role simply acts as an interface i.e. it describes required methods but does not implement them.
There is an example of this in the Moose test suite:
{
package Foo::Bar;
use Moose::Role;
requires 'foo';
requires 'bar';
package Foo::Baz;
use Moose;
sub foo { 'Foo::Baz::FOO' }
sub bar { 'Foo::Baz::BAR' }
sub baz { 'Foo::Baz::BAZ' }
package Foo::Thing;
use Moose;
has 'thing' => (
is => 'rw',
isa => 'Foo::Baz',
handles => 'Foo::Bar',
);
package Foo::OtherThing;
use Moose;
use Moose::Util::TypeConstraints;
has 'other_thing' => (
is => 'rw',
isa => 'Foo::Baz',
handles => Moose::Util::TypeConstraints::find_type_constraint(
+'Foo::Bar'),
);
}
Here you can see that the Foo::Bar role is used to specify delegation, but the actual methods are implemented in Foo::Baz.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|