File: README

package info (click to toggle)
libclass-factory-perl 1.06-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 116 kB
  • ctags: 36
  • sloc: perl: 246; makefile: 2
file content (99 lines) | stat: -rw-r--r-- 2,622 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Class::Factory - Base class for dynamic factory classes
==========================

  package My::Factory;

  use strict;
  use base qw( Class::Factory );

  # Add our default types

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

  # Register optional types

  My::Factory->register_factory_type( java => 'My::Factory::Java' );

  1;

  # Create new objects using the default types

  my $perl_item = My::Factory->new( 'perl', foo => 'bar' );  
  my $blech_item = My::Factory->new( 'blech', foo => 'baz' );  

  # Create new object using the optional type; this library is loaded
  # on the first use

  my $java_item = My::Factory->new( 'java', foo => 'quux' );

  # 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' );

  # Register a new factory type in code

  My::Factory->register_factory_type( bleededge => 'Other::Customized::Class' );
  my $edgy_object = My::Factory->new( 'bleededge', this => 'that' );

  # Get a registered class name given it's factory type
  
  my $registered_class = MyFactory->get_registered_class( 'bleededge' );

  # Remove a factory type

  MyFactory->remove_factory_type('custom');

  # Unregister a factory type

  MyFactory->unregister_factory_type('bleededge');

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.

get_registered_class() was written under the influence of Phix.

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-2007 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.

AUTHORS

Fred Moyer <fred@redhotpenguin.com> is the current maintainer.

Chris Winters <chris@cwinters.com> is the author of Class::Factory.

Eric Andreychek <eric@openthought.net> also helped out with code,
testing and good advice.

Srdjan Jankovic <srdjan@catalyst.net.nz> contributed the idea for
'get_my_factory()' and 'get_my_factory_type()'

Sebastian Knapp <giftnuss@netscape.net> contributed the idea for
'get_registered_class()'

Marcel Gruenauer <marcel@cpan.org> contributed the methods
remove_factory_type() and unregister_factory_type().