| | 81 | } |
| | 82 | |
| | 83 | sub hookable_call_filter { |
| | 84 | my ( $self, $name, @args ) = @_; |
| | 85 | |
| | 86 | Carp::croak "Filter name is not specified." |
| | 87 | if ( ! $name ); |
| | 88 | |
| | 89 | my $prefix = $self->hookable_filter_prefix |
| | 90 | || 'hookable_filter'; |
| | 91 | |
| | 92 | my $filter = $self->hookable_stash->{'filters'}->{$name}; |
| | 93 | $filter ||= $self->can("${prefix}_${name}"); |
| | 94 | $filter ||= sub { return 1 }; |
| | 95 | |
| | 96 | return $filter->( $self, $name, @args ); |
| | 494 | my $bool = $hook->hookable_call_filter( $name => @args ); |
| | 495 | |
| | 496 | This method calls a specified filter. |
| | 497 | |
| | 498 | A filter name is specified as the first argument |
| | 499 | and an argument to a filter is specified as an argument after that. |
| | 500 | |
| | 501 | B<Search of filter>: |
| | 502 | |
| | 503 | This method searches for a filter from several places. |
| | 504 | |
| | 505 | First, when a specified filter is specified by C<$hook-E<gt>hookable_set_filter> method, |
| | 506 | the filter is used. |
| | 507 | |
| | 508 | Next when C<$hook-E<gt>can("${prefix}_${filter_name}")> is defined, |
| | 509 | its method is used as a filter. |
| | 510 | |
| | 511 | C<${prefix}> is return value of $hook->hookable_filter_prefix, |
| | 512 | and C<${filter_name}> is the filter name specified as this method. |
| | 513 | |
| | 514 | When C<$hook-E<gt>hookble_filter_perfix> is not specified, |
| | 515 | C<${prefix}> will be C<'hookable_filter'>. |
| | 516 | |
| | 517 | Please see L<"hookable_filter_prefix"> about C<$hook-E<gt>hookable_filter_prefix>. |
| | 518 | |
| | 519 | When a filter wasn't found, this method uses the filter to which truth is just always returned. |
| | 520 | |