12 package Fake::DateTime;
15 has 'string_repr' => ( is => 'ro' );
19 use Moose::Util::TypeConstraints;
21 coerce 'Fake::DateTime' => from 'Str' =>
22 via { Fake::DateTime->new( string_repr => $_ ) };
24 has 'closing_date' => (
26 isa => 'Fake::DateTime',
29 my ( $self, $val ) = @_;
30 ::pass('... trigger is being called');
31 ::isa_ok( $self->closing_date, 'Fake::DateTime' );
32 ::isa_ok( $val, 'Fake::DateTime' );
38 my $mtg = Mortgage->new( closing_date => 'yesterday' );
39 isa_ok( $mtg, 'Mortgage' );
41 # check that coercion worked
42 isa_ok( $mtg->closing_date, 'Fake::DateTime' );
45 Mortgage->meta->make_immutable;
46 ok( Mortgage->meta->is_immutable, '... Mortgage is now immutable' );
49 my $mtg = Mortgage->new( closing_date => 'yesterday' );
50 isa_ok( $mtg, 'Mortgage' );
52 # check that coercion worked
53 isa_ok( $mtg->closing_date, 'Fake::DateTime' );