Changeset 24453

Show
Ignore:
Timestamp:
11/20/08 17:08:33 (7 weeks ago)
Author:
kazuho
Message:

brush up the design (query is always CODE or CGI::Simple)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/NanoA/trunk/lib/NanoA.pm

    r24452 r24453  
    2424    my $self = bless { 
    2525        config        => $config, 
    26         query         => undef, 
     26        query         => sub { 
     27            require_once('CGI/Simple.pm'); 
     28            no warnings "all"; # suppress 'used only once' 
     29            $CGI::Simple::PARAM_UTF8 = 1; 
     30            CGI::Simple->new(); 
     31        }, 
    2732        headers       => { 
    2833            -type    => 'text/html', 
     
    5863    return $self->{query} = shift 
    5964        if @_; 
    60     if ($self->{query} && ref $self->{query} eq 'CODE') { 
    61         $self->{query} = $self->{query}->($self); 
    62     } 
    63     unless ($self->{query}) { 
    64         require_once('CGI/Simple.pm'); 
    65         no warnings "all"; # suppress 'used only once' 
    66         $CGI::Simple::PARAM_UTF8 = 1; 
    67         $self->{query} = CGI::Simple->new; 
    68     } 
     65    $self->{query} = $self->{query}->($self) 
     66        if ref $self->{query} eq 'CODE'; 
    6967    $self->{query}; 
    7068}