in reply to Delegating to a role in Moose
is that Some::Role simply acts as an interface i.e. it describes required methods but does not implement them.handles => 'Some::Role',
There is an example of this in the Moose test suite:
Here you can see that the Foo::Bar role is used to specify delegation, but the actual methods are implemented in Foo::Baz.{ 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'), ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Delegating to a role in Moose
by nysus (Parson) on Jan 12, 2018 at 15:11 UTC | |
by Arunbear (Prior) on Jan 12, 2018 at 18:22 UTC | |
by nysus (Parson) on Jan 12, 2018 at 21:57 UTC | |
by Arunbear (Prior) on Jan 13, 2018 at 18:14 UTC | |
by nysus (Parson) on Jan 13, 2018 at 21:57 UTC | |
|