Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

class::makemethods::attribute(3pm) [debian man page]

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

NAME
Class::MakeMethods::Attribute - Declare generated subs with attribute syntax SYNOPSIS
package MyObject; use Class::MakeMethods::Attribute 'Standard::Hash'; sub new :MakeMethod('new'); sub foo :MakeMethod('scalar'); sub bar :MakeMethod('scalar', { hashkey => 'bar_data' }); sub debug :MakeMethod('Standard::Global:scalar'); DESCRIPTION
This package allows common types of methods to be generated via a subroutine attribute declaration. (Available in Perl 5.6 and later.) Adding the :MakeMethod() attribute to a subroutine declaration causes Class::MakeMethods to create and install a subroutine based on the parameters given to the :MakeMethod attribute. You can declare a default method-generation class by passing the name of a MakeMethods subclass in the use Class::MakeMethods::Attribute statement. This default method-generation class will also apply as the default to any subclasses declared at compile time. If no default method-generation class is selected, you will need to fully-qualify all method type declarations. EXAMPLE
Here's a typical use of Class::MakeMethods::Attribute: package MyObject; use Class::MakeMethods::Attribute 'Standard::Hash'; sub new :MakeMethod('new'); sub foo :MakeMethod('scalar'); sub bar :MakeMethod('scalar', { hashkey => 'bar_data' }); sub debug :MakeMethod('Standard::Global:scalar'); package MySubclass; use base 'MyObject'; sub bazzle :MakeMethod('scalar'); This is equivalent to the following explicit Class::MakeMethods invocations: package MyObject; use Class::MakeMethods ( -MakerClass => 'Standard::Hash', new => 'new', scalar => 'foo', scalar => [ 'ba', { hashkey => 'bar_data' } ], 'Standard::Global:scalar' => 'debug', ); package MySubclass; use base 'MyObject'; use Class::MakeMethods ( -MakerClass => 'Standard::Hash', scalar => 'bazzle', ); 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.) Can't apply MakeMethod attribute to %s declaration. You can not use the ":MakeMethod" attribute with lexical or anonymous subroutine declarations. No method type provided for MakeMethod attribute. You called ":MakeMethod()" without the required method-type argument. SEE ALSO
See Attribute::Handlers byEDamian Conway. See Class::MakeMethods for general information about this distribution. perl v5.10.1 2004-09-06 MakeMethods::Attribute(3pm)

Check Out this Related Man Page

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

NAME
Class::MakeMethods::Emulator - Demonstrate class-generator equivalency SYNOPSIS
# Equivalent to use Class::Singleton; use Class::MakeMethods::Emulator::Singleton; # Equivalent to use Class::Struct; use Class::MakeMethods::Emulator::Struct; struct ( ... ); # Equivalent to use Class::MethodMaker( ... ); use Class::MakeMethods::Emulator::MethodMaker( ... ); # Equivalent to use base 'Class::Inheritable'; use base 'Class::MakeMethods::Emulator::Inheritable'; MyClass->mk_classdata( ... ); # Equivalent to use base 'Class::AccessorFast'; use base 'Class::MakeMethods::Emulator::AccessorFast'; MyClass->mk_accessors(qw(this that whatever)); # Equivalent to use accessors( ... ); use Class::MakeMethods::Emulator::accessors( ... ); # Equivalent to use mcoder( ... ); use Class::MakeMethods::Emulator::mcoder( ... ); DESCRIPTION
In several cases, Class::MakeMethods provides functionality closely equivalent to that of an existing module, and it is simple to map the existing module's interface to that of Class::MakeMethods. Class::MakeMethods::Emulator provides emulators for Class::MethodMaker, Class::Accessor::Fast, Class::Data::Inheritable, Class::Singleton, Class::Struct, accessors, and mcoder, each of which passes the original module's test suite, usually requiring only the addition of a a single line to each test, activating the emulation module. Beyond demonstrating compatibility, these emulators also generally indicate the changes needed to switch to direct use of Class::MakeMethods functionality, illustrate commonalities between the various modules, and serve as a source for new ideas that can be integrated into Class::MakeMethods. SEE ALSO
See Class::MakeMethods for general information about this distribution. See Class::MakeMethods::Emulator::accessors, and accessors from CPAN. See Class::MakeMethods::Emulator::Struct, and Class::Struct from CPAN. See Class::MakeMethods::Emulator::AccessorFast, and Class::Accessor::Fast from CPAN. See Class::MakeMethods::Emulator::Inheritable, and Class::Data::Inheritable from CPAN. See Class::MakeMethods::Emulator::MethodMaker, and Class::MethodMaker from CPAN. See Class::MakeMethods::Emulator::Singleton, and Class::Singleton from CPAN. See Class::MakeMethods::Emulator::mcoder, and mcoder from CPAN. perl v5.10.1 2004-09-06 MakeMethods::Emulator(3pm)
Man Page