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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

METHODS

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

SUPPORT

126       Bugs should be reported via the CPAN bug tracker at
127
128       http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-Adapter
129       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-Adapter>
130
131       For other issues, contact the author.
132

AUTHOR

134       Adam Kennedy <adamk@cpan.org>
135

SEE ALSO

137       Class::Adapter, Class::Adapter::Clear
138
140       Copyright 2005 - 2010 Adam Kennedy.
141
142       This program is free software; you can redistribute it and/or modify it
143       under the same terms as Perl itself.
144
145       The full text of the license can be found in the LICENSE file included
146       with this module.
147
148
149
150perl v5.12.0                      2010-04-11        Class::Adapter::Builder(3)
Impressum