Commit | Line | Data |
565fe238 |
1 | package MooseX::AttributeHelpers::Number; |
2 | use Moose; |
786dbc3d |
3 | use MooseX::AttributeHelpers::MethodProvider::Number; |
8683383a |
4 | |
5 | extends 'MooseX::AttributeHelpers::Base'; |
565fe238 |
6 | |
c91a1347 |
7 | our $VERSION = '0.02'; |
565fe238 |
8 | our $AUTHORITY = 'cpan:STEVAN'; |
9 | |
786dbc3d |
10 | __PACKAGE__->sugar( |
11 | method_provider => 'Number', |
8683383a |
12 | shortcut => 'Number', |
565fe238 |
13 | ); |
565fe238 |
14 | |
8683383a |
15 | no Moose; |
565fe238 |
16 | |
17 | 1; |
18 | |
8683383a |
19 | __END__ |
20 | |
565fe238 |
21 | =pod |
22 | |
23 | =head1 NAME |
24 | |
25 | MooseX::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 |
55 | This provides a simple numeric attribute, which supports most of the |
720fa35b |
56 | basic math operations. It is important to note that all operations modify the |
57 | value of the attribute in place. |
5431dff2 |
58 | |
8683383a |
59 | =head1 METHOD PROVIDER |
c91a1347 |
60 | |
8683383a |
61 | The methods for this metaclass are provided by |
720fa35b |
62 | L<MooseX::AttributeHelpers::MethodProvider::Number>. |
c91a1347 |
63 | |
565fe238 |
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 | |
8c651099 |
72 | Robert Boone |
565fe238 |
73 | |
74 | =head1 COPYRIGHT AND LICENSE |
75 | |
99c62fb8 |
76 | Copyright 2007-2008 by Infinity Interactive, Inc. |
565fe238 |
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 | |
ae2c330e |
83 | =cut |