Show
Ignore:
Timestamp:
11/28/07 13:34:40 (14 months ago)
Author:
nyarla
Message:

lang/perl/Class-Hookable: I renamed metod: hooks -> hookable_all_hooks

Location:
lang/perl/Class-Hookable/trunk
Files:
2 modified

Legend:

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

    r2101 r2102  
    1010 
    1111sub new { bless {}, shift } 
    12  
    13 sub hooks { 
    14     my ( $self ) =  @_; 
    15  
    16     if ( ref $self->{'Class::Hookable'} ne 'HASH' ) { 
    17         $self->{'Class::Hookable'} = { 
    18             hooks => {}, 
    19         }; 
    20     } 
    21  
    22     return $self->{'Class::Hookable'}->{'hooks'}; 
    23 } 
    2412 
    2513sub hookable_stash { 
     
    5240} 
    5341 
     42sub hookable_all_hooks { 
     43    my $self = shift; 
     44    return $self->hookable_stash->{'hooks'}; 
     45} 
     46 
    5447sub hookable_set_filter { 
    5548    my ( $self, @filters ) = @_; 
     
    113106 
    114107        if ( $self->hookable_call_filter( 'register_hook', $hook, $action ) ) { 
    115             $self->hooks->{$hook} = [] 
    116                 if ( ref $self->hooks->{$hook} ne 'ARRAY' ); 
    117  
    118             push @{ $self->hooks->{$hook} }, $action; 
     108            $self->hookable_all_hooks->{$hook} = [] 
     109                if ( ref $self->hookable_all_hooks->{$hook} ne 'ARRAY' ); 
     110 
     111            push @{ $self->hookable_all_hooks->{$hook} }, $action; 
    119112        } 
    120113    } 
     
    131124    my @hooks = (); 
    132125 
    133     for my $hook ( keys %{ $self->hooks } ) { 
    134         for my $action ( @{ $self->hooks->{$hook} } ) { 
     126    for my $hook ( keys %{ $self->hookable_all_hooks } ) { 
     127        for my $action ( @{ $self->hookable_all_hooks->{$hook} } ) { 
    135128            my $plugin = $action->{'plugin'}; 
    136129            my $class  = ref $plugin || $plugin; 
     
    152145    Carp::croak "Hook name is not specified." if ( ! defined $hook ); 
    153146 
    154     my $list = $self->hooks->{$hook}; 
     147    my $list = $self->hookable_all_hooks->{$hook}; 
    155148       $list ||= []; 
    156149 
     
    166159 
    167160    my $is_class = ( ! ref $object ) ? 1  : 0 ; 
    168     @hooks = keys %{ $self->hooks } if ( @hooks == 0 ); 
     161    @hooks = keys %{ $self->hookable_all_hooks } if ( @hooks == 0 ); 
    169162 
    170163    for my $hook ( $self->registered_hooks( $object ) ) { 
     
    183176        } 
    184177 
    185         $self->hooks->{$hook} = \@actions; 
     178        $self->hookable_all_hooks->{$hook} = \@actions; 
    186179    } 
    187180 
     
    194187 
    195188    if ( @plugins == 0 ) { 
    196         $self->hooks->{$hook} = []; 
     189        $self->hookable_all_hooks->{$hook} = []; 
    197190    } 
    198191    else { 
     
    276269Nothing but that is being done. 
    277270 
    278 =head2 hookable_stash 
    279  
    280   my $data = $hook->hookable_stash; 
    281  
    282 This method is stash in Class::Hookable. 
    283 All variables Class::Hookable needs are put here. 
    284  
    285 This method does not get arguments, 
    286 and return hash reference includes all variables. 
    287  
    288 =head2 hookable_context 
    289  
    290   # set 
    291   $hook->hookable_context( $context ); 
    292   # get 
    293   my $context = $hook->hookable_context; 
    294  
    295 This method is accessor of context object. 
    296  
    297 blessed object or class name is specified as the context object. 
    298  
    299 Context object specified by this method is passed as the second argument of 
    300 the subroutine registered with hook and method. 
    301  
    302 see also L<"run_hook">. 
    303  
    304271=head1 REGISTER METOHDS 
    305272 
     
    418385=item C<$args> 
    419386 
    420 C<$args> specified by the run_hook method. 
     387the argument specified by the run_hook method. 
    421388 
    422389=back 
    423390 
     391B<Arguments of C<$hook-E<gt>hookable_call_filter>>: 
     392 
     393  $hook->hookable_call_filter( 'run_hook', $hook, $args, $action ); 
    424394 
    425395Only when C<$hook-E<gt>hookable_call_filter( 'run_hook', $hook, $args, $action )> has returned truth, 
     
    427397 
    428398Please see L<"hookable_call_filter"> about C<$hook-E<gt>hookable_call_filter>. 
    429  
    430 B<Arguments of C<$hook-E<gt>hookable_call_filter>>: 
    431  
    432   $hook->hookable_call_filter( 'run_hook', $hook, $args, $action ); 
    433399 
    434400=over 4 
     
    591557=head1 ACCESSOR METOHDS 
    592558 
    593 =head2 hooks 
    594  
    595   my $hooks = $hook->hooks; 
     559=head2 hookable_stash 
     560 
     561  my $data = $hook->hookable_stash; 
     562 
     563This method is stash in Class::Hookable. 
     564All variables Class::Hookable needs are put here. 
     565 
     566This method does not get arguments, 
     567and return hash reference includes all variables. 
     568 
     569=head2 hookable_context 
     570 
     571  # set 
     572  $hook->hookable_context( $context ); 
     573  # get 
     574  my $context = $hook->hookable_context; 
     575 
     576This method is accessor of context object. 
     577 
     578blessed object or class name is specified as the context object. 
     579 
     580Context object specified by this method is passed as the second argument of 
     581the subroutine registered with hook and method. 
     582 
     583see also L<"run_hook">. 
     584 
     585=head2 hookable_all_hooks 
     586 
     587  my $hooks = $hook->hookable_all_hooks; 
    596588 
    597589This method is accessor to hash reference which keeps hooks. 
  • lang/perl/Class-Hookable/trunk/t/02_register/00_register_hook.t

    r2101 r2102  
    1616 
    1717is( 
    18     $hook->hooks->{'foo.bar'}->[0]->{'plugin'}, 
     18    $hook->hookable_all_hooks->{'foo.bar'}->[0]->{'plugin'}, 
    1919    $plugin, 
    2020); 
    2121 
    2222is( 
    23     $hook->hooks->{'foo.bar'}->[0]->{'callback'}, 
     23    $hook->hookable_all_hooks->{'foo.bar'}->[0]->{'callback'}, 
    2424    $plugin->can('foo'), 
    2525); 
     
    4747 
    4848is( 
    49     $hook->hooks->{'foo.bar'}->[1], 
     49    $hook->hookable_all_hooks->{'foo.bar'}->[1], 
    5050    undef, 
    5151);