Skip to content

Instantly share code, notes, and snippets.

@gfx
Created July 4, 2011 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfx/1063372 to your computer and use it in GitHub Desktop.
Save gfx/1063372 to your computer and use it in GitHub Desktop.
#!perl -w
use strict;
use Test::More;
{
package A;
use Any::Moose;
use Any::Moose '::Util::TypeConstraints';
use URI;
subtype 'A.URI', as 'URI';
coerce 'A.URI',
from 'Str', via { URI->new($_) };
has base => (
is => 'rw',
isa => 'A.URI',
coerce => 1,
required => 1,
);
__PACKAGE__->meta->make_immutable();
}
my $a = A->new(base => 'http://example.com');
isa_ok $a->base, 'URI';
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment