use Mouse;
use Mouse::Util::TypeConstraints;
- subtype 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } };
+ type 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } };
coerce 'Headers' =>
from 'HashRef' => via {
Response::Headers->new(%{ $_ });
package Request;
use Mouse::Util::TypeConstraints;
- subtype 'Headers' => where { defined $_ && eval { $_->isa('Request::Headers') } };
+ type 'Headers' => where { defined $_ && eval { $_->isa('Request::Headers') } };
};
like $@, qr/The type constraint 'Headers' has already been created, cannot be created again in Request/;
eval {
package Response;
- subtype 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } };
+ type 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } };
};
like $@, qr/The type constraint 'Headers' has already been created, cannot be created again in Response/;
package Request;
use Mouse::Util::TypeConstraints;
- subtype 'Int' => where { 1};
+ type 'Int' => where { 1};
};
like $@, qr/The type constraint 'Int' has already been created, cannot be created again in Request/;
package Foo;
use Mouse;
use Mouse::Util::TypeConstraints;
- subtype Baz => where { defined($_) && $_ eq 'Baz' };
+ type Baz => where { defined($_) && $_ eq 'Baz' };
coerce Baz => from 'ArrayRef', via { 'Baz' };
has 'bar' => ( is => 'rw', isa => 'Str | Baz | Undef', coerce => 1 );
}
use Mouse;
use Mouse::Util::TypeConstraints;
- subtype 'Type1' => where { defined($_) && $_ eq 'Name' };
+ type 'Type1' => where { defined($_) && $_ eq 'Name' };
coerce 'Type1', from 'Str', via { 'Names' };
- subtype 'Type2' => where { defined($_) && $_ eq 'Group' };
+ type 'Type2' => where { defined($_) && $_ eq 'Group' };
coerce 'Type2', from 'Str', via { 'Name' };
has 'foo' => ( is => 'rw', isa => 'Type1|Type2', coerce => 1 );
use Mouse;
use Mouse::Util::TypeConstraints;
- subtype 'Type3' => where { defined($_) && $_ eq 'Name' };
+ type 'Type3' => where { defined($_) && $_ eq 'Name' };
coerce 'Type3', from 'CodeRef', via { 'Name' };
has 'foo' => ( is => 'rw', isa => 'Type3|KLASS|Undef', coerce => 1 );
);
- subtype 'Type4';
+ type 'Type4';
has any => (
is => 'rw',
isa => 'Type4',
use MouseX::Types -declare => [qw/ Headers /];
use MouseX::Types::Mouse 'HashRef';
- subtype Headers, where { defined $_ && eval { $_->isa('Headers1') } };
+ type Headers, where { defined $_ && eval { $_->isa('Headers1') } };
coerce Headers,
from HashRef, via {
Headers1->new(%{ $_ });
use MouseX::Types -declare => [qw/ Headers /];
use MouseX::Types::Mouse 'HashRef';
- subtype Headers, where { defined $_ && eval { $_->isa('Headers2') } };
+ type Headers, where { defined $_ && eval { $_->isa('Headers2') } };
coerce Headers,
from HashRef, via {
Headers2->new(%{ $_ });
use MouseX::Types -declare => [qw/ Baz Type1 Type2 /];
use MouseX::Types::Mouse qw( ArrayRef );
- subtype Baz, where { defined($_) && $_ eq 'Baz' };
+ type Baz, where { defined($_) && $_ eq 'Baz' };
coerce Baz, from ArrayRef, via { 'Baz' };
- subtype Type1, where { defined($_) && $_ eq 'Name' };
+ type Type1, where { defined($_) && $_ eq 'Name' };
coerce Type1, from 'Str', via { 'Names' };
- subtype Type2, where { defined($_) && $_ eq 'Group' };
+ type Type2, where { defined($_) && $_ eq 'Group' };
coerce Type2, from 'Str', via { 'Name' };
}