1Class::Inner(3)       User Contributed Perl Documentation      Class::Inner(3)
2
3
4

NAME

6       Class::Inner - A perlish implementation of Java like inner classes
7

SYNOPSIS

9           use Class::Inner;
10
11           my $object = Class::Inner->new(
12               parent => 'ParentClass',
13               methods => { method => sub { ... } }, },
14               constructor => 'new',
15               args => [@constructor_args],
16           );
17

DESCRIPTION

19       Yet another implementation of an anonymous class with per object
20       overrideable methods, but with the added attraction of sort of working
21       dispatch to the parent class's method.
22
23   METHODS
24       new HASH
25           Takes a hash like argument list with the following keys.
26
27           parent
28               The name of the parent class. Note that you can only get single
29               inheritance with this or SUPER won't work.
30
31           methods
32               A hash, keys are method names, values are CODEREFs.
33
34           constructor
35               The name of the constructor method. Defaults to 'new'.
36
37           args
38               An anonymous array of arguments to pass to the constructor.
39               Defaults to an empty list.
40
41           Returns an object in an 'anonymous' class which inherits from the
42           parent class. This anonymous class has a couple of 'extra' methods:
43
44           SUPER
45               If you were to pass something like
46
47                   $obj = Class::Inner->new(
48                       parent  => 'Parent',
49                       methods => { method =>  sub { ...; $self->SUPER::method(@_) } },
50                   );
51
52               then "$self-"gt"SUPER::method" almost certainly wouldn't do
53               what you expect, so we provide the "SUPER" method which
54               dispatches to the parent implementation of the current method.
55               There seems to be no good way of getting the full "SUPER::"
56               functionality, but I'm working on it.
57
58           DESTROY
59               Because Class::Inner works by creating a whole new class name
60               for your object, it could potentially leak memory if you create
61               a lot of them. So we add a "DESTROY" method that removes the
62               class from the symbol table once it's finished with.
63
64               If you need to override a parent's DESTROY method, adding a
65               call to "Class::Inner::clean_symbol_table(ref $self)" to it. Do
66               it at the end of the method or your other method calls won't
67               work.
68
69       clean_symbol_table
70           The helper subroutine that DESTROY uses to remove the class from
71           the symbol table.
72
73       new_classname
74           Returns a name for the next anonymous class.
75

AUTHOR

77       Maintained by Arun Prasaad  "<arunbear@cpan.org>"
78
79       Copyright (c) 2001 by Piers Cawley <pdcawley@iterative-software.com>.
80
81       All rights reserved. This program is free software; you can
82       redistribute it and/or modify it under the same terms as perl itself.
83
84       Thanks to the Iterative Software people: Leon Brocard, Natalie Ford and
85       Dave Cross. Also, this module was written initially for use in the
86       PerlUnit project, AKA Test::Unit. Kudos to Christian Lemburg and the
87       rest of that team.
88

SEE ALSO

90       There are a million and one differen Class constructors available on
91       CPAN, none of them does quite what I want, so I wrote this one to add
92       to that population where hopefully it will live and thrive.
93

BUGS

95       Bound to be some. Actually the "SUPER" method is a workaround for what
96       I consider to be a bug in perl.
97
98
99
100perl v5.32.0                      2020-07-28                   Class::Inner(3)
Impressum