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

NAME

Hook::Heckle - create pre and post hooks

SYNOPSIS

  use Hook::Heckle;

        my $notify = sub 
        {                       
                my $this = shift;
                
                printf "Model is informing observers because '%s' change\n", $this->victim and $_[0]->notify_observers( 'update' ) if $_[1]; 
                
                @_;                     
        };

        Hook::Heckle->new( context => 'InputField::String', victim => 'max', pre => sub { $_[0]->{aaa} = 1; }, post => $notify );
        
        Hook::Heckle->new( context => 'InputField::String', victim => 'text', post => $notify );

DESCRIPTION

Creating hooks to subroutines is issued by many other cpan modules. See

But this didnt kept me from writing a new one. It is a base class and can be inherited.

CLASSES

Hook::Heckle

PROPERTIES

Any property has a method and parameter to new counterpart.

victim

The method or subroutine to hook at.

context (default: main)

Package name of the method or subroutine.

pre( $this, @_ )

Reference to sub which will be called before execution of the victim. First argument will be the Hook::Heckel object and second the original arguments of the victim.

post( $this, @_ )

Reference to sub which will be called after execution of the victim. First argument will be the Hook::Heckel object and second the original arguments of the victim.

result

Array of the result from the victim.

METHODS

None.

EXPORT

None by default.

AUTHOR

Murat Uenalan, <muenalan@cpan.org>

SEE ALSO

Class::Hook, Hook::Scope, Hook::WrapSub, Hook::LexWrap, Hook::PrePostCall and Class::Maker.