Møøse

Type coercion

subtype 'HTTP::Header'
    => as 'Object'
    => where { $_->isa('HTTP::Headers') };

coerce 'HTTP::Header'
    => from 'ArrayRef'
        => via { HTTP::Headers->new( @{ $_ } ) }
    => from 'HashRef'
        => via { HTTP::Headers->new( %{ $_ } ) };

has 'headers'  => (
    is      => 'rw',
    isa     => 'HTTP::Header',
    coerce  => 1,
);

# ... later ....
$obj->headers([ ... ]);

# ... or
$obj->headers({ ... });

# ... or
$obj->headers(HTTP::Headers->new(...));  
Copyright © 2006 Stevan Little