1Sub::HandlesVia::HandleUrsLeirbrCaornyt:r:iSbcuatleSadurb(P:3e:)rHlanDdolceusmVeinat:a:tHiaonndlerLibrary::Scalar(3)
2
3
4

NAME

6       Sub::HandlesVia::HandlerLibrary::Scalar - library of scalar-related
7       methods
8

SYNOPSIS

10         package My::Class {
11           use Moo;
12           use Sub::HandlesVia;
13           use Types::Standard 'Any';
14           has attr => (
15             is => 'rwp',
16             isa => Any,
17             handles_via => 'Scalar',
18             handles => {
19               'my_make_getter' => 'make_getter',
20               'my_make_setter' => 'make_setter',
21               'my_scalar_reference' => 'scalar_reference',
22             },
23           );
24         }
25

DESCRIPTION

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

DELEGATABLE METHODS

30   make_getter()
31       Returns a getter coderef.
32
33         my $object = My::Class->new( attr => 10 );
34         my $getter = $object->my_make_getter;
35         $object->_set_attr( 11 );
36         say $getter->(); ## ==> 11
37
38   make_setter()
39       Returns a setter coderef.
40
41         my $object = My::Class->new( attr => 10 );
42         my $setter = $object->my_make_setter;
43         $setter->( 11 );
44         say $object->attr; ## ==> 11
45
46   scalar_reference()
47       Returns a scalar reference to the attribute value's slot within its
48       object.
49
50         my $object = My::Class->new( attr => 10 );
51         my $ref = $object->my_scalar_reference;
52         $$ref++;
53         say $object->attr; ## ==> 11
54

BUGS

56       Please report any bugs to
57       <https://github.com/tobyink/p5-sub-handlesvia/issues>.
58

SEE ALSO

60       Sub::HandlesVia.
61

AUTHOR

63       Toby Inkster <tobyink@cpan.org>.
64
66       This software is copyright (c) 2020, 2022 by Toby Inkster.
67
68       This is free software; you can redistribute it and/or modify it under
69       the same terms as the Perl 5 programming language system itself.
70

DISCLAIMER OF WARRANTIES

72       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
73       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
74       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
75
76
77
78perl v5.38.0                      202S3u-b0:7:-H2a1ndlesVia::HandlerLibrary::Scalar(3)
Impressum