1Sub::HandlesVia::HandleUrsLeirbrCaornyt:r:iCbouutSneutdbe:rP:(eH3ra)lndDloecsuVmiean:t:aHtainodnlerLibrary::Counter(3)
2
3
4

NAME

6       Sub::HandlesVia::HandlerLibrary::Counter - library of counter-related
7       methods
8

SYNOPSIS

10         package My::Class {
11           use Moo;
12           use Sub::HandlesVia;
13           use Types::Standard 'Int';
14           has attr => (
15             is => 'rwp',
16             isa => Int,
17             handles_via => 'Counter',
18             handles => {
19               'my_dec' => 'dec',
20               'my_inc' => 'inc',
21               'my_reset' => 'reset',
22               'my_set' => 'set',
23             },
24           );
25         }
26

DESCRIPTION

28       This is a library of methods for Sub::HandlesVia.
29

DELEGATABLE METHODS

31   dec( $amount? )
32       Arguments: Optional[Int].
33
34       Decrements the counter by $amount, or by 1 if no value is given.
35
36         my $object = My::Class->new( attr => 10 );
37         $object->my_dec;
38         $object->my_dec;
39         say $object->attr; ## ==> 8
40         $object->my_dec( 5 );
41         say $object->attr; ## ==> 3
42
43   inc( $amount? )
44       Arguments: Optional[Int].
45
46       Increments the counter by $amount, or by 1 if no value is given.
47
48         my $object = My::Class->new( attr => 0 );
49         $object->my_inc;
50         $object->my_inc;
51         say $object->attr; ## ==> 2
52         $object->my_inc( 3 );
53         say $object->attr; ## ==> 5
54
55   reset()
56       Sets the counter to its default value, or 0 if it has no default.
57
58         my $object = My::Class->new( attr => 10 );
59         $object->my_reset;
60         say $object->attr; ## ==> 0
61
62   set( $value )
63       Arguments: Int.
64
65       Sets the counter to the given value.
66
67         my $object = My::Class->new( attr => 0 );
68         $object->my_set( 5 );
69         say $object->attr; ## ==> 5
70

BUGS

72       Please report any bugs to
73       <https://github.com/tobyink/p5-sub-handlesvia/issues>.
74

SEE ALSO

76       Sub::HandlesVia.
77

AUTHOR

79       Toby Inkster <tobyink@cpan.org>.
80
82       This software is copyright (c) 2020, 2022 by Toby Inkster.
83
84       This is free software; you can redistribute it and/or modify it under
85       the same terms as the Perl 5 programming language system itself.
86

DISCLAIMER OF WARRANTIES

88       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
89       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
90       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
91
92
93
94perl v5.38.0                      20S2u3b-:0:7H-a2n1dlesVia::HandlerLibrary::Counter(3)
Impressum