From: Jesse Luehrs Date: Tue, 10 May 2011 02:42:42 +0000 (-0500) Subject: add example of role-based delegation to Moose::Role synopsis X-Git-Tag: 2.0100~105 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=36fa7a8761ae80260d18a88b738f62568cc6279b;p=gitmo%2FMoose.git add example of role-based delegation to Moose::Role synopsis --- diff --git a/lib/Moose/Role.pm b/lib/Moose/Role.pm index 1cbc9ff..7a22a35 100644 --- a/lib/Moose/Role.pm +++ b/lib/Moose/Role.pm @@ -177,6 +177,23 @@ __END__ $self->as_float == $other->as_float; } + # ... and also + + package Comparator; + use Moose; + + has compare_to => ( + is => 'ro', + does => 'Eq', + handles => 'Eq', + ); + + # ... which allows + + my $currency1 = Currency->new(...); + my $currency2 = Currency->new(...); + Comparator->new(compare_to => $currency1)->equal($currency2); + =head1 DESCRIPTION The concept of roles is documented in L. This document