Class::Factory - Base class for dynamic factory classes
==========================

  package My::Factory;

  use base qw( Class::Factory );

  my %TYPES = ();

  # SIMPLE: Let the parent know about our types

  sub get_factory_map { return \%TYPES }

  # FLEXIBLE: Let the parent know about our types

  sub get_factory_type {
      my ( $class, $type ) = @_;
      return $TYPES{ $type };
  }

  sub set_factory_type {
      my ( $class, $type, $factory_class ) = @_;
      $TYPES{ $type } = $factory_class;
  }

  # Simple factory contructor

  sub new {
      my ( $class, $type, $params ) = @_;
      my $factory_class = $class->get_factory_class( $type );
      return bless( $params, $factory_class );
  }

  # Add our default types

  My::Factory->add_factory_type( perl  => 'My::Factory::Perl' );
  My::Factory->add_factory_type( blech => 'My::Factory::Blech' );

  1;

  # Adding a new factory type in code

  My::Factory->add_factory_type( custom => 'Other::Custom::Class' );
  my $custom_object = My::Factory->new( 'custom', { this => 'that' } );

See POD for details

INSTALLATION

To install this module perform the typical four-part Perl salute:

   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

None, although this module was written almost entirely under the
influence of Weezer.

SIDE-EFFECTS

May include headache, insomnia, and growth spurts, although a control
group given English toffees in place had the same effects.

COPYRIGHT AND LICENCE

Copyright (c) 2002 Chris Winters. All rights reserved.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

AUTHOR

Chris Winters <chris@cwinters.com>