Changeset 15824

Show
Ignore:
Timestamp:
07/15/08 06:35:24 (6 years ago)
Author:
daisuke
Message:

refactor setup()/context() -- this can be handled in BUILD

Location:
lang/perl/Data-Valve/trunk/lib/Data
Files:
3 modified

Legend:

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

    r15823 r15824  
    4343        Class::MOP::load_class($module); 
    4444 
    45         $store = $module->new( %{ $store->{args} } ); 
     45        $store = $module->new( %{ $store->{args} }, context => $self ); 
    4646    } 
    4747    $self->bucket_store($store); 
    48     $store->context($self); 
    49     $store->setup( $self ); 
    5048} 
    5149 
  • lang/perl/Data-Valve/trunk/lib/Data/Valve/BucketStore.pm

    r15597 r15824  
    77 
    88has 'context' => ( 
    9     is => 'rw', 
    10     isa => 'Data::Valve', 
    11     handles => [ qw(max_items interval) ], 
     9    is       => 'rw', 
     10    isa      => 'Data::Valve', 
     11    handles  => [ qw(max_items interval) ], 
    1212); 
    1313 
    1414no Moose; 
    15  
    16 sub setup { 
    17     my ($self, $context) = @_; 
    18     $self->context($context); 
    19 } 
    2015 
    21161; 
  • lang/perl/Data-Valve/trunk/lib/Data/Valve/BucketStore/Memory.pm

    r15597 r15824  
    1111); 
    1212 
    13 after 'setup' => sub { 
    14     my $self = shift; 
    15  
    16     $self->store( { 
    17         __default => $self->create_bucket() 
    18     }); 
    19 }; 
    20  
    2113__PACKAGE__->meta->make_immutable; 
    2214 
    2315no Moose; 
     16 
     17sub BUILD {  
     18    my $self = shift; 
     19    $self->store( { 
     20        __default => $self->create_bucket() 
     21    } ); 
     22} 
    2423 
    2524sub create_bucket