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

NAME

Gapp::App::Role::HasHooks - Role for app with hooks

SYNOPSIS

  package Foo::App;
  
  use Moose;

  extends 'Gapp::App';

  with 'Gapp::App::Role::HasHooks';

  sub BUILD {

    ( $self ) = @_;

    $self->register_hook('init');

  }

  sub init {

    $self->call_hook('init');

  }

  ...

  package main;

  $app = Foo::App->new;
  
  $app->hook( 'init', sub { print 'Hello world!' } );

  $app->init;
  

DESCRIPTION

Hooks are named callbacks points in your application. Hooks can be used to add plugin functionality.

PROVIDED ATTRIBUTES

hooks

HashRef of Gapp::App::Hook objects.

is rw
isa HashRef
default { }
lazy

PROVIDED METHODS

call_hook $hook_name, @params

Will call callbacks for $hook_name, passing in the supplied params. Callbacks are associated with hooks using the hook method.

hook $hook_name, $func, $data

Bind a callback to the given $hook_name.

register_hook $hook_name, %opts?

Register a hook with the application. See <Gapp::App::Hook> for available options.

AUTHORS

Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>

COPYRIGHT & LICENSE

Copyright (c) 2010-2012 Jeffrey Ray Hallock.

    This is free software, licensed under:

    The Artistic License 2.0 (GPL Compatible)