3 use Test::More tests => 6;
8 has 'foo' => ( is => 'rw' );
14 use Mouse::TypeRegistry;
16 subtype 'HeadersType' => sub { defined $_ && eval { $_->isa('Headers') } };
17 coerce 'HeadersType' => +{
19 Headers->new(%{ $_ });
28 has lazy_build_coerce_headers => (
34 sub _build_lazy_build_coerce_headers {
35 Headers->new(foo => 'laziness++')
37 has lazy_coerce_headers => (
42 default => sub { Headers->new(foo => 'laziness++') }
46 my $r = Response->new(headers => { foo => 'bar' });
47 isa_ok($r->headers, 'Headers');
48 is($r->headers->foo, 'bar');
49 $r->headers({foo => 'yay'});
50 isa_ok($r->headers, 'Headers');
51 is($r->headers->foo, 'yay');
52 is($r->lazy_coerce_headers->foo, 'laziness++');
53 is($r->lazy_build_coerce_headers->foo, 'laziness++');