Møøse

Composing Roles from Roles

package Comparable;
use Moose::Role;

with 'Equality';

requires 'compare';

sub equal_to {
    my ($self, $other) = @_;
    $self->compare($other) == 0;
}    

sub greater_than {
    my ($self, $other) = @_;
    $self->compare($other) == 1;
}    

sub less_than {
    my ($self, $other) = @_;
    $self->compare($other) == -1;
}
Copyright © 2006 Stevan Little