Changeset 9563

Show
Ignore:
Timestamp:
04/16/08 17:14:09 (5 years ago)
Author:
nyarla
Message:

lang/perl/Class-Hookable: I implemented clear_methods 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

    r8907 r9563  
    357357} 
    358358 
     359sub clear_methods { 
     360    my ( $self, @methods ) = @_; 
     361    @methods = $self->registered_methods if ( scalar @methods <= 0 ); 
     362 
     363    my $removed = {}; 
     364    for my $method ( @methods ) { 
     365        next if ( ! exists $self->class_hookable_methods->{$method} ); 
     366        $removed->{$method} = delete $self->class_hookable_methods->{$method}; 
     367    } 
     368 
     369    return $removed; 
     370} 
     371 
    359372sub run_hook { 
    360373    my ( $self, $hook, $args, $once, $callback ) = @_; 
     
    11481161 
    11491162When arguments were specified, all plugin registered with specified hooks are deleted, 
    1150 and when arguments are not specified, a plugin is deleted from all hooks. 
     1163and when arguments are not specified, all plugins are deleted from all hooks. 
    11511164 
    11521165A return value of this method is such feeling: 
     
    11681181=head2 clear_methods 
    11691182 
     1183  # clear 'method.A' and 'methodB' 
     1184  $hook->clear_methods(qw( method.A method.B )); 
     1185   
     1186  # clear all 
     1187  $hook->clear_methods; 
     1188   
     1189  my $removed = $hook->clear_methods; 
     1190 
     1191This method deletes all registered method. 
     1192 
     1193An deleted method name is specified as an argument. 
     1194 
     1195When arguments were specified, a plugin registered with specified method is deleted, 
     1196and when arguments are not specified, all plugins are deleted from all methods. 
     1197 
     1198A return value of this method is such feeling: 
     1199 
     1200  $removed = { 
     1201      'method.A' => { plugin => $pluginA, function => $pluginA->can('foo') }, 
     1202      'method.B' => { plugin => $pluginB, function => %pluginB->can('bar') }, 
     1203      ... 
     1204  }; 
     1205 
    11701206=head1 ACCESSOR METOHDS 
    11711207