moose

Type Coercions (cont.)

subtype 'CGI' => as 'Object' => where { $_->isa('CGI') };
coerce 'WebApp::Request'
    => from 'HashRef'
        => via { WebApp::Request->new(params => $_) }
    => from 'CGI'
        => via { 
            my $cgi = shift;
            my $r   = WebApp::Request->new();
            $r->param($_ => $cgi->param($_)) for $cgi->param;
            $r;
        };        
s | << | >> | i