use strict;
use warnings;
use Test::More tests => 4;
-
-{
- package Response::Headers;
- use Mouse;
- has 'foo' => ( is => 'rw' );
-}
-
{
package Response;
use Mouse;
- use Mouse::TypeRegistry;
+ use Mouse::Util::TypeConstraints;
+
+ require t::lib::ClassType_Foo;
- class_type Headers => { class => 'Response::Headers' };
+ # XXX: This below API is different from that of Moose.
+ # class_type() should be class_type 'ClassName';
+ # class_type 'Headers' => { class => 't::lib::ClassType_Foo' };
+ # this should be subtype Headers => as 't::lib::ClassType_foo';
+ subtype 'Headers'
+ => as 't::lib::ClassType_Foo'
+ ;
+
coerce 'Headers' =>
from 'HashRef' => via {
- Response::Headers->new(%{ $_ });
+ t::lib::ClassType_Foo->new(%{ $_ });
},
;
}
my $res = Response->new(headers => { foo => 'bar' });
-isa_ok($res->headers, 'Response::Headers');
+isa_ok($res->headers, 't::lib::ClassType_Foo');
is($res->headers->foo, 'bar');
$res->headers({foo => 'yay'});
-isa_ok($res->headers, 'Response::Headers');
+isa_ok($res->headers, 't::lib::ClassType_Foo');
is($res->headers->foo, 'yay');