From: Dave Rolsky Date: Tue, 10 Feb 2009 19:26:27 +0000 (+0000) Subject: Update code to match changes made in recipe X-Git-Tag: 0.69~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1e1e11ab3697fa75ab4dbeb6da91d1d8c6d9ebcf;p=gitmo%2FMoose.git Update code to match changes made in recipe --- diff --git a/t/000_recipes/basics/005_coercion.t b/t/000_recipes/basics/005_coercion.t index 7643abf..d45cf69 100644 --- a/t/000_recipes/basics/005_coercion.t +++ b/t/000_recipes/basics/005_coercion.t @@ -22,31 +22,38 @@ use Test::Exception; use Params::Coerce (); use URI (); - subtype Header => as Object => where { $_->isa('HTTP::Headers') }; - - coerce Header => from ArrayRef => via { HTTP::Headers->new( @{$_} ) } => - from HashRef => via { HTTP::Headers->new( %{$_} ) }; - - subtype Uri => as Object => where { $_->isa('URI') }; - - coerce Uri => from Object => - via { $_->isa('URI') ? $_ : Params::Coerce::coerce( 'URI', $_ ) } => - from Str => via { URI->new( $_, 'http' ) }; - - subtype Protocol => as Str => where {/^HTTP\/[0-9]\.[0-9]$/}; - - has 'base' => ( is => 'rw', isa => 'Uri', coerce => 1 ); - has 'url' => ( is => 'rw', isa => 'Uri', coerce => 1 ); + class_type('HTTP::Headers'); + + coerce 'HTTP::Headers' + => from 'ArrayRef' + => via { HTTP::Headers->new( @{$_} ) } + => from 'HashRef' + => via { HTTP::Headers->new( %{$_} ) }; + + class_type('URI'); + + coerce 'URI' + => from 'Object' + => via { $_->isa('URI') + ? $_ + : Params::Coerce::coerce( 'URI', $_ ); } + => from 'Str' + => via { URI->new( $_, 'http' ) }; + + subtype 'Protocol' + => as 'Str' + => where { /^HTTP\/[0-9]\.[0-9]$/ }; + + has 'base' => ( is => 'rw', isa => 'URI', coerce => 1 ); + has 'uri' => ( is => 'rw', isa => 'URI', coerce => 1 ); has 'method' => ( is => 'rw', isa => 'Str' ); has 'protocol' => ( is => 'rw', isa => 'Protocol' ); has 'headers' => ( is => 'rw', - isa => 'Header', + isa => 'HTTP::Headers', coerce => 1, default => sub { HTTP::Headers->new } ); - - __PACKAGE__->meta->make_immutable( debug => 0 ); } my $r = Request->new;