Show
Ignore:
Timestamp:
11/18/07 13:48:35 (14 months ago)
Author:
nyarla
Message:

lang/perl/Class-Hookable: I changed the specification of the register_hook method.

Files:
1 modified

Legend:

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

    r1649 r1744  
    2626    my ( $self, $plugin, @hooks ) = @_; 
    2727 
    28     Carp::croak "Plugin object is not blessed object." 
    29         if ( ! Scalar::Util::blessed($plugin) ); 
     28    Carp::croak "Plugin object is not blessed object or class name" 
     29        if ( ref $plugin && ! Scalar::Util::blessed($plugin) ); 
    3030 
    3131    while ( my ( $hook, $callback ) = splice @hooks, 0, 2 ) { 
     
    5959        for my $action ( @{ $self->hooks->{$hook} } ) { 
    6060            my $plugin = $action->{'plugin'}; 
     61            my $class  = ref $plugin || $plugin; 
    6162            if ( $is_class ) { 
    62                 push @hooks, $hook if ( ref $plugin eq $object ); 
     63                push @hooks, $hook if ( $class eq $object ); 
    6364            } 
    6465            else { 
     
    9798        my @actions = (); 
    9899        for my $action ( $self->registered_plugins( $hook ) ) { 
     100            my $plugin  = $action->{'plugin'}; 
     101            my $class   = ref $plugin || $plugin; 
    99102            if ( $is_class ) { 
    100                 push @actions, $action if ( ref $action->{'plugin'} ne $object ); 
     103                push @actions, $action if ( $class ne $object ); 
    101104            } 
    102105            else { 
    103                 push @actions, $action if ( $action->{'plugin'} ne $object ); 
     106                push @actions, $action if ( $plugin ne $object ); 
    104107            } 
    105108        } 
     
    438441=head1 AUTHOR 
    439442 
    440 Naoki Okamura (Nyarla,) E<lt>thotep@nayrla.netE<gt> 
     443Naoki Okamura (Nyarla) E<lt>thotep@nayrla.netE<gt> 
    441444 
    442445=head1 LICENSE