Class::Inner(3pm) | User Contributed Perl Documentation | Class::Inner(3pm) |
Class::Inner - A perlish implementation of Java like inner classes
use Class::Inner; my $object = Class::Inner->new( parent => 'ParentClass', methods => { method => sub { ... } }, }, constructor => 'new', args => [@constructor_args], );
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.
Returns an object in an 'anonymous' class which inherits from the parent class. This anonymous class has a couple of 'extra' methods:
$obj = Class::Inner->new( parent => 'Parent', methods => { method => sub { ...; $self->SUPER::method(@_) } }, );
then "$self-"gt"SUPER::method" almost certainly wouldn't do what you expect, so we provide the "SUPER" method which dispatches to the parent implementation of the current method. There seems to be no good way of getting the full "SUPER::" functionality, but I'm working on it.
If you need to override a parent's DESTROY method, adding a call to "Class::Inner::clean_symbol_table(ref $self)" to it. Do it at the end of the method or your other method calls won't work.
Maintained by Arun Prasaad "<arunbear@cpan.org>"
Copyright (c) 2001 by Piers Cawley <pdcawley@iterative-software.com>.
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.
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, AKA Test::Unit. Kudos to Christian Lemburg and the rest of that team.
There are a million and one differen Class constructors available on CPAN, 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.
Bound to be some. Actually the "SUPER" method is a workaround for what I consider to be a bug in perl.
2022-10-13 | perl v5.36.0 |