Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

method::autoload(3pm) [debian man page]

Method::Autoload(3pm)					User Contributed Perl Documentation				     Method::Autoload(3pm)

NAME
Method::Autoload - Autoloads methods from a list of packages into the current package SYNOPSIS
package MyPackage; use base qw{Method::Autoload} DESCRIPTION
The Method::Autoload base class package is used to autoload methods from a list of packages where you may not know what methods are available until run time. A good use of this package is programming support for user contributed packages or user contributed plugins. USAGE
use MyPackage; my $object=MyPackage->new(%hash); #provides new and initialize methods $object->pushPackages("My::Bar"); #appends to "packages" array $object->unshiftPackages("My::Foo"); #prepends to "packages" array use MyPackage; my $object=MyPackage->new(packages=>["My::Foo", "My::Bar"]); $object->foo; #from My::Foo $object->bar; #from My::Bar CONSTRUCTOR
new my $object=MyPackage->new(%hash); my $object=MyPackage->new(package=>["My::Package1", "My::Package2"]); initialize METHODS PUBLIC
packages Returns the current list of packages in the "packages" array. my @package=$object->packages; #() my $package=$object->packages; #[] pushPackages Pushes packages on to the "packages" array. $object->pushPackages("My::Bar"); $object->pushPackages(@packages); unshiftPackages Unshifts packages on to the "packages" array. Use this if you want to override a "default" package. Please use with care. $object->unshiftPackages("My::Foo"); $object->unshiftPackages(@packages); autoloaded Returns a hash of autoloaded methods and the classes that they came from. my %hash=$object->autoloaded; #() my $hash=$object->autoloaded; #{} METHODS PRIVATE
DESTROY ("Global" method) We define DESTROY in this package so that it does not call AUTOLOAD but you may overload this method in your package, if you need it. AUTOLOAD ("Global" method) AUTOLOAD is a "global" method. Please review the limitations on inheriting this method. autoload my $subref=$object->autoload($class, $method); BUGS
DavisNetworks.com provides support services for all Perl applications including this package. SUPPORT
AUTHOR
Michael R. Davis CPAN ID: MRDVT STOP, LLC domain=>michaelrdavis,tld=>com,account=>perl http://www.stopllc.com/ COPYRIGHT
This program is free software licensed under the... The BSD License The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
Class::Std AUTOMETHOD method, perl v5.12.3 2010-01-21 Method::Autoload(3pm)

Check Out this Related Man Page

MakeMethods::Autoload(3pm)				User Contributed Perl Documentation				MakeMethods::Autoload(3pm)

NAME
Class::MakeMethods::Autoload - Declare generated subs with AUTOLOAD SYNOPSIS
package MyObject; use Class::MakeMethods::Autoload 'Standard::Hash::scalar'; package main; my $obj = bless {}, 'MyObject'; $obj->foo("Foozle"); print $obj->foo(); DESCRIPTION
This package provides a generate-on-demand interface to Class::MakeMethods. When your class uses this package, it imports an AUTOLOAD function that resolves missing methods by using Class::MakeMethods to generate and install a standard type of method. You must specify the type of method to be generated by passing a single argument to your use Class::MakeMethods::Autoload statement, which can take any of these forms: o A Class::MakeMethods generator name and method type. Here are three examples: use Class::MakeMethods::Autoload 'Standard::Hash:scalar'; use Class::MakeMethods::Autoload 'Basic::Universal::no_op'; use Class::MakeMethods::Autoload '::Class::MakeMethod::Composite::Global:array'; o A reference to a subroutine which will be called for each requested function name and which is expected to return the name of the method generator to use. Here's a contrived example which generates scalar accessors for methods except those with a digit in their name, which are treated as globals. use Class::MakeMethods::Autoload sub { my $name = shift; ( $name =~ /d/ ) ? 'Standard::Global::scalar' : 'Standard::Hash::scalar' }; o A reference to a hash which defines which method type to use based on the name of the requested method. If a key exists which is an exact match for the requested function name, the associated value is used; otherwise, each of the keys is used as a regular expression, and the value of the first one that matches the function name is used. (For regular expression matching, the keys are tested in reverse length order, longest to shortest.) Here's an example which provides a new() constructor, a DESTROY() method that does nothing, and a wildcard match that provides scalar accessors for all other Autoloaded methods: use Class::MakeMethods::Autoload { 'new' => 'Standard::Hash::new', '.*' => 'Standard::Hash::scalar', 'DESTROY' => 'Standard::Universal::no_op', }; Here's a more sophisticated example which causes all-upper-case method names to be generated as globals, those with a leading upper- case letter to be generated as inheritable data methods, and others to be normal accessors: use Class::MakeMethods::Autoload { 'new' => 'Standard::Hash::new', '.*' => 'Standard::Hash::scalar', '[A-Z].*' => 'Standard::Inheritable::scalar', '[A-Z0-9]+' => 'Standard::Global::scalar', 'DESTROY' => 'Standard::Universal::no_op', }; DIAGNOSTICS
The following warnings and errors may be produced when using Class::MakeMethods::Attribute to generate methods. (Note that this list does not include run-time messages produced by calling the generated methods, or the standard messages produced by Class::MakeMethods.) No default method type; can't autoload You must declare a default method type, generally by passing its name to a "use Class::MakeMethods::Autoload" statement, prior to autoloading any methods. Construction of %s method %s failed to produce usable method Indicates that Autoload succesfully called Class::MakeMethods->make to generate the requested method, but afterwards was not able to invoke the generated method. You may have selected an incompatible method type, or the method may not have been installed sucesfully. SEE ALSO
See Class::MakeMethods for general information about this distribution. For distribution, installation, support, copyright and license information, see Class::MakeMethods::Docs::ReadMe. perl v5.10.1 2004-09-06 MakeMethods::Autoload(3pm)
Man Page