1Sub::HandlesVia(3)    User Contributed Perl Documentation   Sub::HandlesVia(3)
2
3
4

NAME

6       Sub::HandlesVia - alternative handles_via implementation
7

SYNOPSIS

9        package Kitchen {
10          use Moo;
11          use Sub::HandlesVia;
12          use Types::Standard qw( ArrayRef Str );
13
14          has food => (
15            is          => 'ro',
16            isa         => ArrayRef[Str],
17            handles_via => 'Array',
18            default     => sub { [] },
19            handles     => {
20              'add_food'    => 'push',
21              'find_food'   => 'grep',
22            },
23          );
24        }
25
26        my $kitchen = Kitchen->new;
27        $kitchen->add_food('Bacon');
28        $kitchen->add_food('Eggs');
29        $kitchen->add_food('Sausages');
30        $kitchen->add_food('Beans');
31
32        my @foods = $kitchen->find_food(sub { /^B/i });
33

DESCRIPTION

35       If you've used Moose's native attribute traits, or MooX::HandlesVia
36       before, you should have a fairly good idea what this does.
37
38       Why re-invent the wheel? Well, this is an implementation that should
39       work okay with Moo, Moose, Mouse, and any other OO toolkit you throw at
40       it.  One ring to rule them all, so to speak.
41
42       For details of how to use it, see the manual.
43
44       Sub::HandlesVia::Manual::WithMoo
45           How to use Sub::HandlesVia with Moo and Moo::Role.
46
47       Sub::HandlesVia::Manual::WithMoose
48           How to use Sub::HandlesVia with Moose and Moose::Role.
49
50       Sub::HandlesVia::Manual::WithMouse
51           How to use Sub::HandlesVia with Mouse and Mouse::Role.
52
53       Sub::HandlesVia::Manual::WithMite
54           How to use Sub::HandlesVia with Mite.
55
56       Sub::HandlesVia::Manual::WithClassTiny
57           How to use Sub::HandlesVia with Class::Tiny.
58
59       Sub::HandlesVia::Manual::WithObjectPad
60           How to use Sub::HandlesVia with Object::Pad classes.
61
62       Sub::HandlesVia::Manual::WithGeneric
63           How to use Sub::HandlesVia with other OO toolkits, and hand-written
64           Perl classes.
65
66       Note: as Sub::HandlesVia needs to detect which toolkit you are using,
67       and often needs to detect whether your package is a class or a role, it
68       needs to be loaded after Moo/Moose/Mouse/etc. Your "use Moo" or "use
69       Moose::Role" or whatever needs to be before your "use Sub::HandlesVia".
70

BUGS

72       Please report any bugs to
73       <https://github.com/tobyink/p5-sub-handlesvia/issues>.
74
75       (There are known bugs for Moose native types that do coercion.)
76

SEE ALSO

78       Guides for use with different OO toolkits:
79       Sub::HandlesVia::Manual::WithMoo, Sub::HandlesVia::Manual::WithMoose,
80       Sub::HandlesVia::Manual::WithMouse, Sub::HandlesVia::Manual::WithMite,
81       Sub::HandlesVia::Manual::WithClassTiny,
82       Sub::HandlesVia::Manual::WithObjectPad,
83       Sub::HandlesVia::Manual::WithGeneric.
84
85       Documentation for delegatable methods:
86       Sub::HandlesVia::HandlerLibrary::Array,
87       Sub::HandlesVia::HandlerLibrary::Blessed,
88       Sub::HandlesVia::HandlerLibrary::Bool,
89       Sub::HandlesVia::HandlerLibrary::Code,
90       Sub::HandlesVia::HandlerLibrary::Counter,
91       Sub::HandlesVia::HandlerLibrary::Enum,
92       Sub::HandlesVia::HandlerLibrary::Hash,
93       Sub::HandlesVia::HandlerLibrary::Number,
94       Sub::HandlesVia::HandlerLibrary::Scalar, and
95       Sub::HandlesVia::HandlerLibrary::String.
96
97       Other implementations of the same concept:
98       Moose::Meta::Attribute::Native, MouseX::NativeTraits, and
99       MooX::HandlesVia with Data::Perl.
100
101       Comparison of those: Sub::HandlesVia::Manual::Comparison
102
103       Sub::HandlesVia::Declare is a helper for declaring Sub::HandlesVia
104       delegations at compile-time, useful for Object::Pad and (to a lesser
105       extent) Class::Tiny.
106

AUTHOR

108       Toby Inkster <tobyink@cpan.org>.
109
111       This software is copyright (c) 2020, 2022 by Toby Inkster.
112
113       This is free software; you can redistribute it and/or modify it under
114       the same terms as the Perl 5 programming language system itself.
115

DISCLAIMER OF WARRANTIES

117       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
118       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
119       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
120
121
122
123perl v5.38.0                      2023-07-21                Sub::HandlesVia(3)
Impressum