Show
Ignore:
Timestamp:
12/17/07 14:34:39 (13 months ago)
Author:
nyarla
Message:

lang/perl/Class-Hookable: I implemented delete_function method.

Location:
lang/perl/Class-Hookable/trunk
Files:
1 added
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Class-Hookable/trunk/lib/Class/Hookable.pm

    r2980 r3205  
    275275} 
    276276 
     277sub delete_function { 
     278    my ( $self, $function, @methods ) = @_; 
     279 
     280    Carp::croak "Function is not CODE reference." 
     281        if ( ref $function ne 'CODE' ); 
     282 
     283    @methods = $self->registered_methods 
     284        if ( @methods == 0 ); 
     285 
     286    for my $method ( @methods ) { 
     287        my $action = $self->registered_function( $method ); 
     288        if ( $action->{'function'} eq $function ) { 
     289            $self->delete_method( $method ); 
     290        } 
     291    } 
     292} 
     293 
    277294sub delete_plugin { 
    278295    my ( $self, $object, @hooks ) = @_; 
     
    369386I thank Tatsuhiko Miyagawa and Plagger contributors. 
    370387 
     388B<NOTE>: 
     389 
     390Class::Hookable is having substantial changes from version 0.02 to version0.03. 
     391When using Class::Hookable, please be careful. 
     392 
     393Please see Changes file about a change point. 
     394 
    371395=head1 BASIC METHOD 
    372396 
     
    731755and some hook names are specified after that. 
    732756 
    733 When specifying a callback as an argument, 
     757When specifying only a callback as an argument, 
    734758all callbacks registered with the hook are deleted. 
    735759 
     
    743767This method deleted a registered hookable method. 
    744768The method name is specified as an argument. 
     769 
     770=head2 delete_function 
     771 
     772  $hook->delete_function( $plugin->can('function') );: 
     773  $hook->delete_function( \&function => qw( method.A method.B ) ); 
     774 
     775This method deletes a registered function. 
     776 
     777Function (CODE reference) is specified as the first argument. 
     778and some method names are specified after that. 
     779 
     780When specifying only a function as an argument, 
     781all functions registered with the method are deleted. 
     782 
     783And when specifying function and method names as arguments, 
     784specified functions are deleted from specified methods.  
    745785 
    746786=head2 delete_plugin 
     
    795835all method of Class::Hookable is accessing hooks through this method. 
    796836 
    797 =head1 hookable_all_methods 
     837=head2 hookable_all_methods 
    798838 
    799839  my $methods = $hook->hookable_all_methods;