Moose Moose - It's the new camel #13

Comparable Role

package Comparable;

use Moose::Role;

requires 'compare';

sub greater_than {
    my ($self, $value) = @_;
    return ($self->compare($value) == 1) ? 1 : 0;
}

sub less_than {
    my ($self, $value) = @_;
    return ($self->compare($value) == -1) ? 1 : 0;
}

sub equal {
    my ($self, $value) = @_;
    return ($self->compare($value) == 0) ? 1 : 0;
}

1;
continued...
Copyright © 2007 Robert Boone