The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Konstrukt::Attributes - Sub attribute handling

SYNOPSIS

        #define a method with an attribute
        sub some_sub :some_attr {
                #...
        }
        
        #check if a sub has a specified attribute
        $Konstrukt::Attributes->has(\&some_sub => 'some_attr');

DESCRIPTION

This module collects the attribute definitions for the methods of the (loaded) plugins and allows to check if a given method has a specified attribute.

With this information you may for example decide to execute a method or not.

Attributes are primarily used in Konstrukt::SimplePlugin.

To enable the attribute collection your module must import the MODIFY_CODE_ATTRIBUTES of this package. This can be done this way:

        use base 'Konstrukt::Attributes';

METHODS

new

Constructor of this class

init

Initialization.

has

Returns true if the given sub has a specified attribute.

Parameters:

  • $coderef - Coderef to the sub/method

  • $attribute - The name of the attribute

INTERNALS

MODIFY_CODE_ATTRIBUTES

This sub does the real work. It captures the definition of attributes during compile time and saves them for later use.

AUTHOR

Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.

This document is free software. It is distributed under the same terms as Perl itself.

SEE ALSO

Konstrukt