1Class::Adapter::BuilderU(s3e)r Contributed Perl DocumentaCtliaosns::Adapter::Builder(3)
2
3
4

NAME

6       Class::Adapter::Builder - Generate Class::Adapter classes
7

VERSION

9       version 1.09
10

SYNOPSIS

12         package My::Adapter;
13
14         use strict;
15         use Class::Adapter::Builder
16             ISA     => 'Specific::API',
17             METHODS => [ qw{foo bar baz} ],
18             method  => 'different_method';
19
20         1;
21

DESCRIPTION

23       "Class::Adapter::Builder" is another mechanism for letting you create
24       Adapter classes of your own.
25
26       It is intended to act as a toolkit for generating the guts of many
27       varied and different types of Adapter classes.
28
29       For a simple base class you can inherit from and change a specific
30       method, see Class::Adapter::Clear.
31
32   The Pragma Interface
33       The most common method for defining Adapter classes, as shown in the
34       synopsis, is the pragma interface.
35
36       This consists of a set of key/value pairs provided when you load the
37       module.
38
39         # The format for building Adapter classes
40         use Class::Adapter::Builder PARAM => VALUE, ...
41
42       ISA The "ISA" param is provided as either a single value, or a
43           reference to an "ARRAY" containing is list of classes.
44
45           Normally this is just a straight list of classes. However, if the
46           value for "ISA" is set to '_OBJECT_' the object will identify
47           itself as whatever is contained in it when the "->isa" and "->can"
48           method are called on it.
49
50       NEW Normally, you need to create your "Class::Adapter" objects
51           separately:
52
53             # Create the object
54             my $query = CGI->new( 'param1', 'param2' );
55
56             # Create the Decorator
57             my $object = My::Adapter->new( $query );
58
59           If you provide a class name as the "NEW" param, the Decorator will
60           do this for you, passing on any constructor arguments.
61
62             # Assume we provided the following
63             # NEW => 'CGI',
64
65             # We can now do the above in one step
66             my $object = My::Adapter->new( 'param1', 'param2' );
67
68       AUTOLOAD
69           By default, a "Class::Adapter" does not pass on any methods, with
70           the methods to be passed on specified explicitly with the 'METHODS'
71           param.
72
73           By setting "AUTOLOAD" to true, the "Adapter" will be given the
74           standard "AUTOLOAD" function to to pass through all unspecified
75           methods to the parent object.
76
77           By default the AUTOLOAD will pass through any and all calls,
78           including calls to private methods.
79
80           If the AUTOLOAD is specifically set to 'PUBLIC', the AUTOLOAD
81           setting will ONLY apply to public methods, and any private methods
82           will not be passed through.
83
84       METHODS
85           The "METHODS" param is provided as a reference to an array of all
86           the methods that are to be passed through to the parent object as
87           is.
88
89       Any params other than the ones specified above are taken as translated
90       methods.
91
92         # If you provide the following
93         # foo => bar
94
95         # It the following are equivalent
96         $decorator->foo;
97         $decorator->_OBJECT_->bar;
98
99       This capability is provided primarily because in Perl one of the main
100       situations in which you hit the limits of Perl's inheritance model is
101       when your class needs to inherit from multiple different classes that
102       containing clashing methods.
103
104       For example:
105
106         # If your class is like this
107         package Foo;
108
109         use base 'This', 'That';
110
111         1;
112
113       If both "This->method" exists and "That->method" exists, and both mean
114       different things, then "Foo->method" becomes ambiguous.
115
116       A "Class::Adapter" could be used to wrap your "Foo" object, with the
117       "Class::Adapter" becoming the "That" sub-class, and passing
118       "$decorator->method" through to "$object->that_method".
119

METHODS

121       Yes, "Class::Adapter::Builder" has public methods and later on you will
122       be able to access them directly, but for now they are remaining
123       undocumented, so that I can shuffle things around for another few
124       versions.
125
126       Just stick to the pragma interface for now.
127

SEE ALSO

129       Class::Adapter, Class::Adapter::Clear
130

SUPPORT

132       Bugs may be submitted through the RT bug tracker
133       <https://rt.cpan.org/Public/Dist/Display.html?Name=Class-Adapter> (or
134       bug-Class-Adapter@rt.cpan.org <mailto:bug-Class-Adapter@rt.cpan.org>).
135

AUTHOR

137       Adam Kennedy <adamk@cpan.org>
138
140       This software is copyright (c) 2005 by Adam Kennedy.
141
142       This is free software; you can redistribute it and/or modify it under
143       the same terms as the Perl 5 programming language system itself.
144
145
146
147perl v5.32.0                      2020-07-28        Class::Adapter::Builder(3)
Impressum