| | 233 | sub delete_hook { |
| | 234 | my ( $self, $hook, @plugins ) = @_; |
| | 235 | |
| | 236 | Carp::croak "Hook is not specified." if ( ! defined $hook ); |
| | 237 | |
| | 238 | if ( @plugins == 0 ) { |
| | 239 | $self->hookable_all_hooks->{$hook} = []; |
| | 240 | } |
| | 241 | else { |
| | 242 | for my $plugin ( @plugins ) { |
| | 243 | $self->delete_plugin( $plugin, $hook ); |
| | 244 | } |
| | 245 | } |
| | 246 | } |
| | 247 | |
| | 248 | sub delete_callback { |
| | 249 | my ( $self, $callback, @hooks ) = @_; |
| | 250 | |
| | 251 | Carp::croak "Callback is not CODE reference." |
| | 252 | if ( ref $callback ne 'CODE' ); |
| | 253 | |
| | 254 | @hooks = $self->registered_hooks |
| | 255 | if ( @hooks == 0 ); |
| | 256 | |
| | 257 | for my $hook ( @hooks ) { |
| | 258 | my @new; |
| | 259 | for my $action ( $self->registered_callbacks( $hook ) ) { |
| | 260 | if ( $action->{'callback'} ne $callback ) { |
| | 261 | push @new, $action; |
| | 262 | } |
| | 263 | } |
| | 264 | $self->hookable_all_hooks->{$hook} = \@new; |
| | 265 | } |
| | 266 | } |
| | 267 | |
| 692 | | specified plugins are deleted from a specified hook. |
| | 712 | specified plugins are deleted from specified hooks. |
| | 713 | |
| | 714 | =head2 delete_callback |
| | 715 | |
| | 716 | $hook->delete_callback( $plugin->can('callback') ); |
| | 717 | $hook->delete_callback( \&callback => qw( hook.A hook.B ) ); |
| | 718 | |
| | 719 | This method deletes a registered callback. |
| | 720 | |
| | 721 | Callback (CODE reference) is specified as the first argument, |
| | 722 | and some hook names are specified after that. |
| | 723 | |
| | 724 | When specifying a callback as an argument, |
| | 725 | all callbacks registered with the hook are deleted. |
| | 726 | |
| | 727 | And When specifying callback and hook names as arguments, |
| | 728 | specified callbacks are deleted from specified hooks. |