Changeset 11561 for dan

Show
Ignore:
Timestamp:
05/14/08 12:28:25 (6 months ago)
Author:
aerith
Message:

dan/perl/closxop: 配列のときもループ

Location:
dan/perl/closxop/lib
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • dan/perl/closxop/lib/Closxop.pm

    r11559 r11561  
    6666        my $path = sprintf "%s/%s/Plugin", $self->config->global->plugin_dir, ref $self; 
    6767 
    68         $self->plugins([]); 
     68        $self->{plugins} = []; 
     69 
    6970        if ( -d $path && -r _ ) { 
    7071                unshift @INC, $self->config->global->plugin_dir; 
  • dan/perl/closxop/lib/Closxop/DataStruct.pm

    r11557 r11561  
    1010        my $data  = shift || {}; 
    1111 
    12         unless ( ref $data eq 'HASH' ) { 
    13                 Carp::croak qq(This data may be invalid.); 
    14         } 
    15  
    16         for my $key ( %{ $data } ) { 
    17                 if ( ref $data->{$key} eq 'HASH' ) { 
    18                         $data->{$key} = $class->new($data->{$key}); 
     12        if ( ref $data eq 'HASH' ) { 
     13                foreach my $key ( %{ $data } ) { 
     14                        if ( ref $data->{$key} eq 'HASH' ) { 
     15                                $data->{$key} = $class->new($data->{$key}); 
     16                        } elsif ( ref $data->{$key} eq 'ARRAY' ) { 
     17                                foreach my $index ( $#{ $data->{$key} } ) { 
     18                                if ( ref $data->{$key}->[$index] eq 'HASH' ) { 
     19                                        $data->{$key}->[$index] = $class->new($data->{$key}->[$index]); 
     20                                } 
     21                        } 
    1922                } 
    2023        } 
     24} 
    2125 
    2226        bless { _data => $data }, $class; 
  • dan/perl/closxop/lib/Closxop/Plugin.pm

    r11557 r11561  
    1414        my $config = $context->config; 
    1515 
    16         return $self unless 
    17                 exists $config->{plugins} && 
    18                 ref $config->{plugins} eq 'ARRAY'; 
     16        return $self unless $config->plugins && ref $config->plugins eq 'ARRAY'; 
    1917 
    20         foreach my $object ( @{ $config->{plugins} } ) { 
    21                 next unless 
    22                         exists $object->{module} && 
    23                         exists $object->{config}; 
     18        foreach my $object ( @{ $config->plugins } ) { 
     19                next unless $object->module && $object->config; 
    2420 
    25                 if ( $self->plugin_name eq $object->{module} ) { 
    26                         $self->plugin_config($object->{config}); 
     21                warn ref $object; 
    2722 
    28                         my $priority = $self->plugin_config->{priority}; 
     23                if ( $self->plugin_name eq $object->module ) { 
     24                        $self->plugin_config($object->config); 
     25 
     26                        my $priority = $self->plugin_config->priority; 
    2927                        $self->priority( $priority ? int $priority : 100 ); 
    3028