Changeset 9993
- Timestamp:
- 04/20/08 18:47:56 (5 years ago)
- Location:
- lang/perl/Class-Hookable/trunk
- Files:
-
- 3 modified
- 1 moved
-
lib/Class/Hookable.pm (modified) (4 diffs)
-
t/50_call (moved) (moved from lang/perl/Class-Hookable/trunk/t/04_call)
-
t/50_call/00_run_hook.t (modified) (2 diffs)
-
t/50_call/01_call_method.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Class-Hookable/trunk/lib/Class/Hookable.pm
r9563 r9993 381 381 } 382 382 383 384 383 my @results; 385 384 386 my $context = ( defined $self-> hookable_context ) ? $self->hookable_context : $self ;387 388 for my $action ( $self->registered_callbacks( $hook )) {389 if ( $self-> hookable_call_filter( 'run_hook', $hook, $args, $action) ) {385 my $context = ( defined $self->class_hookable_context ) ? $self->class_hookable_context : $self ; 386 387 for my $action ( @{ $self->class_hookable_hooks->{$hook} || [] } ) { 388 if ( $self->class_hookable_filter( 'run_hook', $hook, $action, $args ) ) { 390 389 my $plugin = $action->{'plugin'}; 391 390 my $result = $action->{'callback'}->( $plugin, $context, $args ); 392 391 $callback->( $result ) if ( $callback ); 393 392 if ( $once ) { 394 return $result if ( defined $ once);393 return $result if ( defined $result ); 395 394 } 396 395 else { … … 416 415 } 417 416 418 my $context = ( defined $self-> hookable_context )419 ? $self-> hookable_context417 my $context = ( defined $self->class_hookable_context ) 418 ? $self->class_hookable_context 420 419 : $self ; 421 420 422 my $action = $self->registered_function( $method );421 my $action = $self->class_hookable_methods->{$method}; 423 422 return if ( ! $action ); 424 423 425 if ( $self-> hookable_call_filter( 'call_method', $method, $args, $action) ) {424 if ( $self->class_hookable_filter( 'call_method', $method, $action, $args ) ) { 426 425 my ( $plugin, $function ) = @{ $action }{qw( plugin function )}; 427 426 my $result = $function->( $plugin, $context, $args ); … … 596 595 =back 597 596 598 B<Arguments of C<$hook-E<gt>hookable_call_filter>>: 599 600 $hook->hookable_call_filter( 'run_hook', $hook, $args, $action ); 601 602 Only when C<$hook-E<gt>hookable_call_filter( 'run_hook', $hook, $args, $action )> has returned truth, 597 Only when C<$hook-E<gt>class_hookable_filter( 'run_hook', $hook, $action, $args )> has returned truth, 603 598 this method calls callback. 604 599 605 Please see L<"hookable_call_filter"> about C<$hook-E<gt>hookable_call_filter>. 606 607 =over 608 609 =item 'run_hook' 610 611 C<'run_hook'> is filter name. 612 613 =item C<$hook> 614 615 The hook name specified by the run_hook method. 616 617 =item C<$args> 618 619 The argument specified by the run_hook method. 620 621 =item C<$action> 622 623 my ( $plugin, $callback ) = @{ $action }{qw( plugin callback )}; 624 625 The hash reference including the plugin and the callback. 626 627 =back 600 Please see L<"class_hookable_filter"> about C<$hook-E<gt>class_hookable_filter>. 628 601 629 602 =head2 run_hook_once … … 687 660 =back 688 661 689 B<Arguments of C<$hook-E<gt>hookable_call_filter>>: 690 691 $hook->hookable_call_filter( 'call_method', $method, $args, $action ); 692 693 Only when C<$hook-E<gt>hookable_call_filter( 'call_method', $method, $args, $action )> has returned truth, 662 Only when C<$hook-E<gt>class_hookable_filter( 'call_method', $method, $action, $args )> has returned truth, 694 663 this method calls function. 695 664 696 Please see L<"hookable_call_filter"> about C<$hook-E<gt>hookable_call_filter>. 697 698 =over 699 700 =item C<'call_method'> 701 702 C<'call_method'> is filter name. 703 704 =item C<$method> 705 706 The function name specified by the call_method method. 707 708 =item C<$args> 709 710 The argument specified by the call_method method. 711 712 =item C<$action> 713 714 my ( $plugin, $function ) = @{ $action }{qw( plugin function )}; 715 716 The hash reference including the plugin and the function. 717 718 =back 665 Please see L<"class_hookable_filter"> about C<$hook-E<gt>class_hookable_filter>. 719 666 720 667 =head1 FILTER METHODS -
lang/perl/Class-Hookable/trunk/t/50_call/00_run_hook.t
r4056 r9993 53 53 # -- context test -------------------- # 54 54 55 $hook-> hookable_context( Context->new );55 $hook->class_hookable_context( Context->new ); 56 56 57 57 $hook->run_hook_once('context'); … … 65 65 # -- dispatch_plugin test ------------ # 66 66 67 $hook-> hookable_set_filter(67 $hook->class_hookable_set_filter( 68 68 'run_hook' => sub { 69 my ( $self, $filter, $hook, $a rgs, $action) = @_;69 my ( $self, $filter, $hook, $action, $args ) = @_; 70 70 71 71 isa_ok( $self, 'Class::Hookable' ); -
lang/perl/Class-Hookable/trunk/t/50_call/01_call_method.t
r4056 r9993 43 43 # -- context test -------------------- # 44 44 45 $hook-> hookable_context( Context->new );45 $hook->class_hookable_context( Context->new ); 46 46 $hook->call_method('context'); 47 47 … … 53 53 # -- filter test --------------------- # 54 54 55 $hook-> hookable_set_filter(55 $hook->class_hookable_set_filter( 56 56 'call_method' => sub { 57 my ( $self, $filter, $method, $a rgs, $action) = @_;57 my ( $self, $filter, $method, $action, $args ) = @_; 58 58 59 59 isa_ok( $self, 'Class::Hookable' );
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)