1Moose::Meta::Attribute:U:sNeartiCvoenM:to:roTisrbeau:it:teM:de:tCPaoe:ur:nlAtteDtror(ci3ub)muetnet:a:tNiaotnive::Trait::Counter(3)
2
3
4

NAME

6       Moose::Meta::Attribute::Native::Trait::Counter - Helper trait for Int
7       attributes which represent counters
8

VERSION

10       version 2.2015
11

SYNOPSIS

13         package MyHomePage;
14         use Moose;
15
16         has 'counter' => (
17             traits  => ['Counter'],
18             is      => 'ro',
19             isa     => 'Num',
20             default => 0,
21             handles => {
22                 inc_counter   => 'inc',
23                 dec_counter   => 'dec',
24                 reset_counter => 'reset',
25             },
26         );
27
28         my $page = MyHomePage->new();
29         $page->inc_counter;    # same as $page->counter( $page->counter + 1 );
30         $page->dec_counter;    # same as $page->counter( $page->counter - 1 );
31
32         my $count_by_twos = 2;
33         $page->inc_counter($count_by_twos);
34

DESCRIPTION

36       This trait provides native delegation methods for counters. A counter
37       can be any sort of number (integer or not). The delegation methods
38       allow you to increment, decrement, or reset the value.
39

DEFAULT TYPE

41       If you don't provide an "isa" value for your attribute, it will default
42       to "Num".
43

PROVIDED METHODS

45set($value)
46
47           Sets the counter to the specified value and returns the new value.
48
49           This method requires a single argument.
50
51inc
52
53inc($arg)
54
55           Increases the attribute value by the amount of the argument, or by
56           1 if no argument is given. This method returns the new value.
57
58           This method accepts a single argument.
59
60dec
61
62dec($arg)
63
64           Decreases the attribute value by the amount of the argument, or by
65           1 if no argument is given. This method returns the new value.
66
67           This method accepts a single argument.
68
69reset
70
71           Resets the value stored in this slot to its default value, and
72           returns the new value.
73

BUGS

75       See "BUGS" in Moose for details on reporting bugs.
76

AUTHORS

78       •   Stevan Little <stevan@cpan.org>
79
80       •   Dave Rolsky <autarch@urth.org>
81
82       •   Jesse Luehrs <doy@cpan.org>
83
84       •   Shawn M Moore <sartak@cpan.org>
85
86       •   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
87
88       •   Karen Etheridge <ether@cpan.org>
89
90       •   Florian Ragwitz <rafl@debian.org>
91
92       •   Hans Dieter Pearcey <hdp@cpan.org>
93
94       •   Chris Prather <chris@prather.org>
95
96       •   Matt S Trout <mstrout@cpan.org>
97
99       This software is copyright (c) 2006 by Infinity Interactive, Inc.
100
101       This is free software; you can redistribute it and/or modify it under
102       the same terms as the Perl 5 programming language system itself.
103
104
105
106perl v5.34.0                 Moose2:0:2M1e-t0a7:-:2A2ttribute::Native::Trait::Counter(3)
Impressum