Composite now implemented.
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Number.pm
1 package MooseX::AttributeHelpers::Number;
2 use Moose;
3 use MooseX::AttributeHelpers::MethodProvider::Number;
4
5 extends 'MooseX::AttributeHelpers::Base';
6
7 our $VERSION   = '0.02';
8 our $AUTHORITY = 'cpan:STEVAN';
9
10 __PACKAGE__->sugar(
11     method_provider  => 'Number',
12     shortcut         => 'Number',
13 );
14
15 no Moose;
16
17 1;
18
19 __END__
20
21 =pod
22
23 =head1 NAME
24
25 MooseX::AttributeHelpers::Number
26
27 =head1 SYNOPSIS
28   
29   package Real;
30   use Moose;
31   use MooseX::AttributeHelpers;
32   
33   has 'integer' => (
34       metaclass => 'Number',
35       is        => 'ro',
36       isa       => 'Int',
37       default   => sub { 5 },
38       provides  => {
39           set => 'set',
40           add => 'add',
41           sub => 'sub',
42           mul => 'mul',
43           div => 'div',
44           mod => 'mod',
45           abs => 'abs',
46       }
47   );
48
49   my $real = Real->new();
50   $real->add(5); # same as $real->integer($real->integer + 5);
51   $real->sub(2); # same as $real->integer($real->integer - 2);  
52   
53 =head1 DESCRIPTION
54
55 This provides a simple numeric attribute, which supports most of the
56 basic math operations.  It is important to note that all operations modify the
57 value of the attribute in place.
58
59 =head1 METHOD PROVIDER
60
61 The methods for this metaclass are provided by
62 L<MooseX::AttributeHelpers::MethodProvider::Number>.
63
64 =head1 BUGS
65
66 All complex software has bugs lurking in it, and this module is no 
67 exception. If you find a bug please either email me, or add the bug
68 to cpan-RT.
69
70 =head1 AUTHOR
71
72 Robert Boone
73
74 =head1 COPYRIGHT AND LICENSE
75
76 Copyright 2007-2008 by Infinity Interactive, Inc.
77
78 L<http://www.iinteractive.com>
79
80 This library is free software; you can redistribute it and/or modify
81 it under the same terms as Perl itself.
82
83 =cut