Composite now implemented.
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Number.pm
CommitLineData
565fe238 1package MooseX::AttributeHelpers::Number;
2use Moose;
786dbc3d 3use MooseX::AttributeHelpers::MethodProvider::Number;
8683383a 4
5extends 'MooseX::AttributeHelpers::Base';
565fe238 6
c91a1347 7our $VERSION = '0.02';
565fe238 8our $AUTHORITY = 'cpan:STEVAN';
9
786dbc3d 10__PACKAGE__->sugar(
11 method_provider => 'Number',
8683383a 12 shortcut => 'Number',
565fe238 13);
565fe238 14
8683383a 15no Moose;
565fe238 16
171;
18
8683383a 19__END__
20
565fe238 21=pod
22
23=head1 NAME
24
25MooseX::AttributeHelpers::Number
26
27=head1 SYNOPSIS
28
29 package Real;
5431dff2 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 );
565fe238 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
5431dff2 55This provides a simple numeric attribute, which supports most of the
720fa35b 56basic math operations. It is important to note that all operations modify the
57value of the attribute in place.
5431dff2 58
8683383a 59=head1 METHOD PROVIDER
c91a1347 60
8683383a 61The methods for this metaclass are provided by
720fa35b 62L<MooseX::AttributeHelpers::MethodProvider::Number>.
c91a1347 63
565fe238 64=head1 BUGS
65
66All complex software has bugs lurking in it, and this module is no
67exception. If you find a bug please either email me, or add the bug
68to cpan-RT.
69
70=head1 AUTHOR
71
8c651099 72Robert Boone
565fe238 73
74=head1 COPYRIGHT AND LICENSE
75
99c62fb8 76Copyright 2007-2008 by Infinity Interactive, Inc.
565fe238 77
78L<http://www.iinteractive.com>
79
80This library is free software; you can redistribute it and/or modify
81it under the same terms as Perl itself.
82
ae2c330e 83=cut