Skip to content

Instantly share code, notes, and snippets.

@peczenyj
Created October 19, 2011 20:38
Show Gist options
  • Save peczenyj/1299589 to your computer and use it in GitHub Desktop.
Save peczenyj/1299589 to your computer and use it in GitHub Desktop.
Exemplo de Role + Delegation
package Closeable;
use Moose::Role;
requires 'close';
1;
package Connector;
use Moose;
has 'client' => (
is => 'rw',
isa => 'Client',
required => 1,
handles => 'Closeable',
);
with 'Closeable';
__PACKAGE__->meta->make_immutable;
no Moose;
1;
package Client;
use Moose;
sub close {
print 666;
}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
my $c = Connector->new (client => Client->new);
$c->close;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment