GX::Callback::Hook

Module Version: 0.2000_01

NAME

GX::Callback::Hook - Hook class

SYNOPSIS

# Load the class
use GX::Callback::Hook;

# Create a new hook object
$hook = GX::Callback::Hook->new;

# Add a callback
$hook->add( GX::Callback->new( sub { say 'Hello!' } ) );

DESCRIPTION

This module provides the GX::Callback::Hook class which extends the GX::Class::Object class.

METHODS

Constructor

new

Returns a new GX::Callback::Hook object.

$hook = GX::Callback::Hook->new( %attributes );
Attributes:
  • name ( string | undef )

    The name of the hook.

Returns:

Alternative syntax

$hook = GX::Callback::Hook->new( $name );
Arguments:
  • $name ( string | undef )

    The name of the hook.

Returns:

Public Methods

add

Adds a callback object.

$hook->add( $callback );
$hook->add( $callback, $priority );
Arguments:
  • $callback ( GX::Callback object )
  • $priority ( integer ) [ optional ]

    Defaults to PRIORITY_NORMAL (see CONSTANTS below).

Exceptions:

all

Returns all callback objects.

@callbacks = $hook->all;
Returns:

name

Returns the name of the hook.

$name = $hook->name;
Returns:
  • $name ( string | undef )

remove

Removes the given callback object.

$result = $hook->remove( $callback );
Arguments:
Returns:
  • $result ( bool )
Exceptions:

remove_all

Removes all callbacks objects.

$hook->remove_all;

CONSTANTS

PRIORITY_HIGHEST => 0
PRIORITY_HIGH => 2
PRIORITY_NORMAL => 4
PRIORITY_LOW => 6
PRIORITY_LOWEST => 8

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright © 2009-2011 Jörg A. Uzarek.

This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.