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


Manual Reference Pages  -  CLASS::MAKEMETHODS::ATTRIBUTE (3)

.ds Aq ’

NAME

Class::MakeMethods::Attribute - Declare generated subs with attribute syntax

CONTENTS

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 byE\k:^Damian Conway.

See Class::MakeMethods for general information about this distribution.

POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 139: Non-ASCII character seen before =encoding in ’byE\k:^Damian’. Assuming ISO8859-1
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MAKEMETHODS::ATTRIBUTE (3) 2004-09-06

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