BUGS
[gitmo/Moose.git] / lib / Moose / Cookbook / Recipe6.pod
1
2 =pod
3
4 =head1 NAME
5
6 Moose::Cookbook::Recipe6 - The Moose::Role example
7
8 =head1 SYNOPSIS
9   
10   package Eq;
11   use strict;
12   use warnings;
13   use Moose::Role;
14   
15   requires 'equal_to';
16   
17   sub not_equal_to { 
18       my ($self, $other) = @_;
19       !$self->equal_to($other);
20   }
21   
22   package Ord;
23   use strict;
24   use warnings;
25   use Moose::Role;
26   
27   with 'Eq';
28   
29   requires 'compare';
30   
31   sub equal_to {
32       my ($self, $other) = @_;
33       $self->compare($other) == 0;
34   }    
35   
36   sub greater_than {
37       my ($self, $other) = @_;
38       $self->compare($other) == 1;
39   }    
40   
41   sub less_than {
42       my ($self, $other) = @_;
43       $self->compare($other) == -1;
44   }
45   
46   sub greater_than_or_equal_to {
47       my ($self, $other) = @_;
48       $self->greater_than($other) || $self->equal_to($other);
49   }        
50   
51   sub less_than_or_equal_to {
52       my ($self, $other) = @_;
53       $self->less_than($other) || $self->equal_to($other);
54   }    
55   
56   package US::Currency;
57   use strict;
58   use warnings;
59   use Moose;
60   
61   with 'Ord';
62   
63   has 'amount' => (is => 'rw', isa => 'Int', default => 0);
64   
65   sub compare {
66       my ($self, $other) = @_;
67       $self->amount <=> $other->amount;
68   }
69   
70 =head1 DESCRIPTION
71
72 Coming Soon. 
73
74 =head1 AUTHOR
75
76 Stevan Little E<lt>stevan@iinteractive.comE<gt>
77
78 =head1 COPYRIGHT AND LICENSE
79
80 Copyright 2006 by Infinity Interactive, Inc.
81
82 L<http://www.iinteractive.com>
83
84 This library is free software; you can redistribute it and/or modify
85 it under the same terms as Perl itself.
86
87 =cut       
88