GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Badger::Factory::Class(3) User Contributed Perl Documentation Badger::Factory::Class(3)

Badger::Factory::Class - class module for Badger::Factory sub-classes

This module can be used to create subclasses of Badger::Factory.

    package My::Widgets;
    
    use Badger::Factory::Class
        version => 0.01,
        item    => 'widget',
        path    => 'My::Widget Your::Widget',
        widgets => {
            extra => 'Another::Widget::Module',
            super => 'Golly::Gosh',
        },
        names   => {
            html  => 'HTML',
            color => 'Colour',
        };

    package main;
    
    # class method
    my $widget = My::Widgets->widget( foo => @args );
    
    # object method
    my $widgets = My::Widgets->new;
    my $widget  = $widgets->widget( foo => @args );

This module is a subclass of Badger::Class specialised for the purpose of creating Badger::Factory subclasses. It is used by the Badger::Codecs module among others.

The following methods are provided in addition to those inherited from the Badger::Class base class.

The singular name of the item that the factory manages. This is used to set the $ITEM package variable for Badger::Factory to use.

The plural name of the item that the factory manages. This is used to set the $ITEMS package variable for Badger::Factory to use.

A list of module names that form the search path when loading modules. This will set the relevant package variable depending on the value of $ITEMS (or the regular plural form of $ITEM if $ITEMS is undefined). For example, is $ITEMS is set to "widgets" then this method will set $WIDGETS_PATH.

You can specify the path as a reference to a list of module bases, e.g.

    use Badger::Factory::Class
        item => 'widget',
        path => ['My::Widget', 'Your::Widget'];

Or as a single string containing multiple values separated by whitespace.

    use Badger::Factory::Class
        item => 'widget',
        path => 'My::Widget Your::Widget';

If you specify it as a single string then you can also include optional and/or alternate parts in parentheses. For example the above can be written more concisely as:

    use Badger::Factory::Class
        item => 'widget',
        path => '(My|Your)::Widget';

If the parentheses don't contain a vertical bar then then enclosed fragment is treated as being optional. So instead of writing something like:

    use Badger::Factory::Class
        item => 'widget',
        path => 'Badger::Widget BadgerX::Widget';

You can write:

    use Badger::Factory::Class
        item => 'widget',
        path => 'Badger(X)::Widget';

See the permute_fragments() function in Badger::Utils for further details on how fragments are expanded.

A reference to a hash array of name mappings. This can be used to handle any unusual spellings or capitalisations. See Badger::Factory for further details.

The default name to use when none is specified in a request for a module.

Andy Wardley <http://wardley.org/>

Copyright (C) 2006-2009 Andy Wardley. All Rights Reserved.

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

Badger::Factory, Badger::Codecs
2016-12-12 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.