Class::Container 0.12 review

Download
by rbytes.net on

Class::Container is a Perl module with Glues object frameworks together transparently. SYNOPSIS package Car; use Class::Cont

License: Perl Artistic License
File size: 18K
Developer: Ken Williams
0 stars award from rbytes.net

Class::Container is a Perl module with Glues object frameworks together transparently.

SYNOPSIS

package Car;
use Class::Container;
@ISA = qw(Class::Container);

__PACKAGE__->valid_params
(
paint => {default => 'burgundy'},
style => {default => 'coupe'},
windshield => {isa => 'Glass'},
radio => {isa => 'Audio::Device'},
);

__PACKAGE__->contained_objects
(
windshield => 'Glass::Shatterproof',
wheel => { class => 'Vehicle::Wheel',
delayed => 1 },
radio => 'Audio::MP3',
);

sub new {
my $package = shift;

# 'windshield' and 'radio' objects are created automatically by
# SUPER::new()
my $self = $package->SUPER::new(@_);

$self->{right_wheel} = $self->create_delayed_object('wheel');
... do any more initialization here ...
return $self;
}

This class facilitates building frameworks of several classes that inter-operate. It was first designed and built for HTML::Mason, in which the Compiler, Lexer, Interpreter, Resolver, Component, Buffer, and several other objects must create each other transparently, passing the appropriate parameters to the right class, possibly substituting other subclasses for any of these objects.

The main features of Class::Container are:

Explicit declaration of containment relationships (aggregation, factory creation, etc.)
Declaration of constructor parameters accepted by each member in a class framework
Transparent passing of constructor parameters to the class that needs them
Ability to create one (automatic) or many (manual) contained objects automatically and transparently

Requirements:
Perl

Class::Container 0.12 search tags