1Class::Adapter(3) User Contributed Perl Documentation Class::Adapter(3)
2
3
4
6 Class::Adapter - Perl implementation of the "Adapter" Design Pattern
7
9 The "Class::Adapter" class is intended as an abstract base class for
10 creating any sort of class or object that follows the Adapter pattern.
11
12 What is an Adapter?
13 The term Adapter refers to a "Design Pattern" of the same name, from
14 the famous "Gang of Four" book "Design Patterns". Although their
15 original implementation was designed for Java and similar single-
16 inheritance strictly-typed langauge, the situation for which it applies
17 is still valid.
18
19 An Adapter in this Perl sense of the term is when a class is created to
20 achieve by composition (objects containing other object) something that
21 can't be achieved by inheritance (sub-classing).
22
23 This is similar to the Decorator pattern, but is intended to be applied
24 on a class-by-class basis, as opposed to being able to be applied one
25 object at a time, as is the case with the Decorator pattern.
26
27 The "Class::Adapter" object holds a parent object that it "wraps", and
28 when a method is called on the "Class::Adapter", it manually calls the
29 same (or different) method with the same (or different) parameters on
30 the parent object contained within it.
31
32 Instead of these custom methods being hooked in on an object-by-object
33 basis, they are defined at the class level.
34
35 Basically, a "Class::Adapter" is one of your fall-back positions when
36 Perl's inheritance model fails you, or is no longer good enough, and
37 you need to do something twisty in order to make several APIs play
38 nicely with each other.
39
40 What can I do with the actual Class::Adapter class
41 Well... nothing really. It exist to provide some extremely low level
42 fundamental methods, and to provide a common base for inheritance of
43 Adapter classes.
44
45 The base "Class::Adapter" class doesn't even implement a way to push
46 method calls through to the underlying object, since the way in which
47 that happens is the bit that changes from case to case.
48
49 To actually DO something, you probably want to go take a look at
50 Class::Adapter::Builder, which makes the creation of Adapter classes
51 relatively quick and easy.
52
54 The "Class::Adapter" class itself supplies only the two most common
55 methods, a default constructor and a private method to access the
56 underlying object.
57
58 new $object
59 The default "new" constructor takes a single object as argument and
60 creates a new object which holds the passed object.
61
62 Returns a new "Class::Adapter" object, or "undef" if you do not pass in
63 an object.
64
65 _OBJECT_
66 The "_OBJECT_" method is provided primarily as a convenience, and a
67 tool for people implementing sub-classes, and allows the
68 "Class::Adapter" interface to provide a guarenteed correct way of
69 getting to the underlying object, should you need to do so.
70
72 Bugs should be reported via the CPAN bug tracker at
73
74 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-Adapter
75 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Class-Adapter>
76
77 For other issues, contact the author.
78
80 - Write more comprehensive tests
81
83 Adam Kennedy <adamk@cpan.org>
84
86 Class::Adapter::Clear, Class::Adapter::Builder, Class::Decorator
87
89 Copyright 2005 - 2010 Adam Kennedy.
90
91 This program is free software; you can redistribute it and/or modify it
92 under the same terms as Perl itself.
93
94 The full text of the license can be found in the LICENSE file included
95 with this module.
96
97
98
99perl v5.12.0 2010-04-11 Class::Adapter(3)