use strict; use warnings; package Foo; use Moose; use TmpTypes qw(NewType); has 'item' => (isa => NewType, is => 'rw', required => 1, coerce => 1); sub is_new { my ($self, $item) = @_; return "Yup, ($item) is new!\n" if (is_NewType($item)); return "Nope, ($item) is old.\n"; } package main; use TmpTypes qw(NewType); my $obj = Foo->new(item => 'car'); my $thing = $obj->item; print "Is $thing new? ".$obj->is_new($thing); $thing = 'house'; print "Is $thing new? ".$obj->is_new($thing); $thing = to_NewType('House'); print "Is $thing new? ".$obj->is_new($thing);