Class::Inner

Class::Inner is a perlish implementation of Java like inner classes.
Download

Class::Inner Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Piers Cawley
  • Publisher web site:
  • http://search.cpan.org/~pdcawley/

Class::Inner Tags


Class::Inner Description

Class::Inner is a perlish implementation of Java like inner classes. Class::Inner is a perlish implementation of Java like inner classes.SYNOPSIS use Class::Inner; my $object = Class::Inner->new( parent => 'ParentClass', methods => { method => sub { ... } }, }, constructor => 'new', 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.METHODSnew HASHTakes a hash like argument list with the following keys.parentThe name of the parent class. Note that you can only get single inheritance with this or SUPER won't work.methodsA hash, keys are method names, values are CODEREFs.constructorThe name of the constructor method. Defaults to 'new'.argsAn anonymous array of arguments to pass to the constructor. Defaults to an empty list.Returns an object in an 'anonymous' class which inherits from the parent class. This anonymous class has a couple of 'extra' methods:SUPERIf you were to pass something like $obj = Class::Inner->new( parent => 'Parent', methods => { method => sub { ...; $self->SUPER::method(@_) } }, );then $self-gtSUPER::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.DESTROYBecause Class::Inner 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 DESTROY method that removes the class from the symbol table once it's finished with.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.clean_symbol_tableThe helper subroutine that DESTROY uses to remove the class from the symbol table.new_classnameReturns a name for the next anonymous class. Requirements: · Perl


Class::Inner Related Software