Show
Ignore:
Timestamp:
11/28/07 11:08:33 (14 months ago)
Author:
nyarla
Message:

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

    r2020 r2097  
    5656 
    5757    while ( my ( $method, $filter ) = splice @filters, 0, 2 ) { 
     58        Carp::croak "Invalid filter name. you can use [a-zA-Z_]" 
     59            if ( $method =~ m{[^a-zA-Z_]} ); 
     60 
    5861        Carp::croak "filter is not CODE reference." 
    5962            if ( ref $filter ne 'CODE' ); 
     
    6265    } 
    6366 
     67} 
     68 
     69sub hookable_filter_prefix { 
     70    my $self = shift; 
     71 
     72    if ( @_ ) { 
     73        my $prefix = shift; 
     74        Carp::croak "Invalid filter prefix. you can use [a-zA-Z_]" 
     75            if ( $prefix =~ m{[^a-zA-Z_]} ); 
     76        $self->hookable_stash->{'filter_prefix'} = $prefix; 
     77    } 
     78    else { 
     79        return $self->hookable_stash->{'filter_prefix'}; 
     80    } 
    6481} 
    6582 
     
    443460 
    444461  $hook->hookable_set_filter( 
    445       run_hook => \&myfilter, 
     462      register_hook => \&filterA 
     463      run_hook      => \&filterB, 
    446464  ); 
    447465 
    448466This method registers the filter of hook and method. 
     467 
     468Arguments are specified by the order of C<'name' =E<gt> \&filter>. 
     469The character which can be used for the filter name is C<[a-zA-Z_]>. 
    449470 
    450471When registering a homonymous filter of the filter registered already, 
     
    466487 
    467488=back 
     489 
     490=head2 hookable_filter_prefix 
     491 
     492  $hook->hookable_filter_prefix('myfilter_prefix'); 
     493 
     494This method is accessor of filter prefix; 
     495 
     496When finding filter in call_filer_method, 
     497prefix specified by this method is used. 
     498 
     499The character which can be used for the filter prefix is C<[a-zA-Z_]>. 
    468500 
    469501=head1 UTILITY METHODS