Changeset 8743

Show
Ignore:
Timestamp:
04/03/08 16:16:40 (8 months ago)
Author:
yappo
Message:

lang/perl/HTTP-MobileAttribute?: Plugin のアクセサメソッドは一度登録したら二度と登録しなくていいよ

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/HTTP-MobileAttribute/trunk/lib/HTTP/MobileAttribute/Plugin.pm

    r8740 r8743  
    66sub mk_register_accessors { 
    77    my $self    = shift; 
     8    return if $self->{__method_registerd}; 
    89    my $carrier = shift; 
    910    my $class   = ref $self; 
     
    1213    for my $method (@_) { 
    1314        no strict 'refs'; 
    14         *{"$class\::$method"} = sub { shift->{$method} } unless *{"$class\::$method"}{CODE}; 
     15        *{"$class\::$method"} = sub { shift->{$method} }; 
    1516        $pkg->register_method( $method => $self ); 
    1617    } 
     18    $self->{__method_registerd} = 1; 
    1719} 
    1820 
     
    2022    my($self, $c) = @_; 
    2123    for my $key (keys %{ $self }) { 
    22         delete $self->{$key} unless $key eq 'config'; 
     24        delete $self->{$key} unless $key eq 'config' || $key eq '__method_registerd'; 
    2325    } 
    2426}