Changeset 2120 for lang/perl/Class-Hookable/trunk/lib/Class/Hookable.pm
- Timestamp:
- 11/28/07 17:33:25 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Class-Hookable/trunk/lib/Class/Hookable.pm
r2102 r2120 115 115 116 116 sub registered_hooks { 117 my ( $self, $object ) = @_; 118 119 if ( ref $object && ! Scalar::Util::blessed( $object ) ) { 120 Carp::croak "Argument is not blessed object or class name."; 121 } 122 123 my $is_class = ( ! ref $object ) ? 1 : 0 ; 124 my @hooks = (); 125 126 for my $hook ( keys %{ $self->hookable_all_hooks } ) { 127 for my $action ( @{ $self->hookable_all_hooks->{$hook} } ) { 128 my $plugin = $action->{'plugin'}; 129 my $class = ref $plugin || $plugin; 130 if ( $is_class ) { 131 push @hooks, $hook if ( $class eq $object ); 132 } 133 else { 134 push @hooks, $hook if ( $plugin eq $object ); 117 my $self = shift; 118 119 my @hooks; 120 121 if ( @_ > 0 ) { 122 my $object = shift; 123 124 if ( ref $object && ! Scalar::Util::blessed( $object ) ) { 125 Carp::croak "Argument is not blessed object or class name."; 126 } 127 128 my $is_class = ( ! ref $object ) ? 1 : 0 ; 129 130 for my $hook ( keys %{ $self->hookable_all_hooks } ) { 131 for my $action ( @{ $self->hookable_all_hooks->{$hook} } ) { 132 my $plugin = $action->{'plugin'}; 133 my $class = ref $plugin || $plugin; 134 if ( $is_class ) { 135 push @hooks, $hook if ( $class eq $object ); 136 } 137 else { 138 push @hooks, $hook if ( $plugin eq $object ); 139 } 135 140 } 136 141 } 142 } 143 else { 144 @hooks = keys %{ $self->hookable_all_hooks }; 137 145 } 138 146 … … 516 524 my @hooks = $hook->registered_hooks( 'ClassName' ); 517 525 518 This method returns hooks with which a plugin is registered. 519 An argument is plugin object or class name. 526 This method returns a registered hook name. 527 528 When calling without arguments, all registered hook name is returned. 529 and when specifying plugin obejct (or Class name) as an argument, 530 the hook name with which a plugin is registered is returned. 520 531 521 532 =head2 registered_plugins … … 532 543 533 544 $hook->delete_plugin( $plugin ); 534 $hook->delete_plugin( 'ClassName', 'hook.A', 'hook.B');545 $hook->delete_plugin( ClassName => qw( hook.A hook.B ) ); 535 546 536 547 This method delete a registered plugin. … … 545 556 546 557 $hook->delete_hook( 'hook.name' ); 547 $hook->delete_hook( 'hook.name' , $pluginA, 'ClassName');558 $hook->delete_hook( 'hook.name' => ( $pluginA, 'ClassName' ) ); 548 559 549 560 This method delete a registered hook.
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)