.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Class::Inner 3pm" .TH Class::Inner 3pm "2018-01-18" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Class::Inner \- A perlish implementation of Java like inner classes .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Class::Inner; \& \& my $object = Class::Inner\->new( \& parent => \*(AqParentClass\*(Aq, \& methods => { method => sub { ... } }, }, \& constructor => \*(Aqnew\*(Aq, \& args => [@constructor_args], \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Yet another implementation of an anonymous class with per object overrideable methods, but with the added attraction of sort of working dispatch to the parent class's method. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" .IP "\fBnew \s-1HASH\s0\fR" 4 .IX Item "new HASH" Takes a hash like argument list with the following keys. .RS 4 .IP "\fBparent\fR" 4 .IX Item "parent" The name of the parent class. Note that you can only get single inheritance with this or \fB\s-1SUPER\s0\fR won't work. .IP "\fBmethods\fR" 4 .IX Item "methods" A hash, keys are method names, values are CODEREFs. .IP "\fBconstructor\fR" 4 .IX Item "constructor" The name of the constructor method. Defaults to 'new'. .IP "\fBargs\fR" 4 .IX Item "args" An anonymous array of arguments to pass to the constructor. Defaults to an empty list. .RE .RS 4 .Sp Returns an object in an 'anonymous' class which inherits from the parent class. This anonymous class has a couple of 'extra' methods: .IP "\fB\s-1SUPER\s0\fR" 4 .IX Item "SUPER" If you were to pass something like .Sp .Vb 4 \& $obj = Class::Inner\->new( \& parent => \*(AqParent\*(Aq, \& methods => { method => sub { ...; $self\->SUPER::method(@_) } }, \& ); .Ve .Sp then \f(CW\*(C`$self\-\f(CW\*(C`gt\*(C'\f(CWSUPER::method\*(C'\fR almost certainly wouldn't do what you expect, so we provide the \f(CW\*(C`SUPER\*(C'\fR method which dispatches to the parent implementation of the current method. There seems to be no good way of getting the full \f(CW\*(C`SUPER::\*(C'\fR functionality, but I'm working on it. .IP "\fB\s-1DESTROY\s0\fR" 4 .IX Item "DESTROY" Because \fBClass::Inner\fR works by creating a whole new class name for your object, it could potentially leak memory if you create a lot of them. So we add a \f(CW\*(C`DESTROY\*(C'\fR method that removes the class from the symbol table once it's finished with. .Sp If you need to override a parent's \s-1DESTROY\s0 method, adding a call to \&\f(CW\*(C`Class::Inner::clean_symbol_table(ref $self)\*(C'\fR to it. Do it at the end of the method or your other method calls won't work. .RE .RS 4 .RE .IP "\fBclean_symbol_table\fR" 4 .IX Item "clean_symbol_table" The helper subroutine that \s-1DESTROY\s0 uses to remove the class from the symbol table. .IP "\fBnew_classname\fR" 4 .IX Item "new_classname" Returns a name for the next anonymous class. .SH "AUTHOR" .IX Header "AUTHOR" Maintained by Arun Prasaad \f(CW\*(C`\*(C'\fR .PP Copyright (c) 2001 by Piers Cawley . .PP All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as perl itself. .PP Thanks to the Iterative Software people: Leon Brocard, Natalie Ford and Dave Cross. Also, this module was written initially for use in the PerlUnit project, \s-1AKA\s0 Test::Unit. Kudos to Christian Lemburg and the rest of that team. .SH "SEE ALSO" .IX Header "SEE ALSO" There are a million and one differen Class constructors available on \s-1CPAN,\s0 none of them does quite what I want, so I wrote this one to add to that population where hopefully it will live and thrive. .SH "BUGS" .IX Header "BUGS" Bound to be some. Actually the \f(CW\*(C`SUPER\*(C'\fR method is a workaround for what I consider to be a bug in perl.