Role-Basic

 view release on metacpan or  search on metacpan

examples/currency.pl  view on Meta::CPAN

    use Role::Basic 'with';

    with 'Comparable', 'Printable';

    # note that writing this constructor would not be needed with Moose and it
    # would have better validation
    sub new {
        my ( $class, $arg_for ) = @_;
        $arg_for ||= {};
        my $amount = $arg_for->{amount} || 0;
        bless { amount => $amount } => $class;
    }

    sub amount {
        my $self = shift;
        return $self->{amount} unless @_;
        $self->{amount} = shift;
    }

    sub compare {
        my ( $self, $other ) = @_;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.251 second using v1.00-cache-2.02-grep-82fe00e-cpan-9f2165ba459b )