-=head2 C<load>
-
-=cut
-
-sub load {
- my ($tc, $thing) = @_;
-
- # When ->check is called inside coerce, a return value of 0 means that
- # coercion should take place, while 1 signifies that the value is already
- # OK.
-
- # First, try a possible user defined constraint
- my $user = $tc->user_constraint;
- if (defined $user) {
- my $ok = $user->($thing);
- return 1 if $ok;
- }
-
- # Then, try the parent constraint
- return 1 if $tc->parent->check($thing);
-
- # If $thing isn't even an object, don't bother trying to coerce it
- my $class = blessed($thing);
- return 0 unless defined $class;
-
- # Find the file to autoload
- my $mapper = $tc->mapper;
- my $pm = $class = $tc->$mapper($class);
- $pm =~ s{::}{/}g;
- $pm .= '.pm';
- return 0 if $INC{$pm}; # already loaded
-
- local $@;
- eval { require $pm; 1 };
-
- return 0;
-}
-