Changeset 15823

Show
Ignore:
Timestamp:
07/15/08 06:29:42 (5 years ago)
Author:
daisuke
Message:

BUILDの引数はこう使うのか。

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Data-Valve/trunk/lib/Data/Valve.pm

    r15793 r15823  
    2828); 
    2929 
    30 around 'new' => sub { 
    31     my ($next, $class, %args) = @_; 
     30__PACKAGE__->meta->make_immutable; 
    3231 
    33     my $store = delete $args{bucket_store} || { module => 'Memory' }; 
     32no Moose; 
     33 
     34sub BUILD { 
     35    my ($self, $args) = @_; 
     36 
     37    my $store = delete $args->{bucket_store} || { module => 'Memory' }; 
    3438    if (! blessed $store) { 
    3539        my $module = $store->{module}; 
     
    4145        $store = $module->new( %{ $store->{args} } ); 
    4246    } 
    43  
    44     my $self = $next->($class, %args, bucket_store => $store); 
    45  
    46     return $self; 
    47 }; 
    48  
    49 __PACKAGE__->meta->make_immutable; 
    50  
    51 no Moose; 
    52  
    53 sub BUILD { 
    54     my $self = shift; 
    55     $self->bucket_store->context($self); 
    56     $self->bucket_store->setup( $self ); 
     47    $self->bucket_store($store); 
     48    $store->context($self); 
     49    $store->setup( $self ); 
    5750} 
    5851