my $pkg = shift || caller();
return if $pkg eq ':no_export';
no strict 'refs';
- foreach my $export (qw(type subtype as where to coerce)) {
+ foreach my $export (qw(type subtype as where coerce from via)) {
*{"${pkg}::${export}"} = \&{"${export}"};
}
}
}
sub as ($) { $_[0] }
+sub from ($) { $_[0] }
sub where (&) { $_[0] }
-sub to (&) { $_[0] }
+sub via (&) { $_[0] }
# define some basic types
=> where { $_ < 10 };
coerce Num
- => as Str
- => to { 0+$_ };
+ => from Str
+ => via { 0+$_ };
=head1 DESCRIPTION
=item B<coerce>
-=item B<to>
+=item B<from>
+
+=item B<via>
=back
use Moose;
coerce 'HTTPHeader'
- => as ArrayRef
- => to { HTTPHeader->new(array => $_[0]) }
- => as HashRef
- => to { HTTPHeader->new(hash => $_[0]) };
+ => from ArrayRef
+ => via { HTTPHeader->new(array => $_[0]) }
+ => from HashRef
+ => via { HTTPHeader->new(hash => $_[0]) };
has 'array' => (is => 'ro');
has 'hash' => (is => 'ro');
=> where { $_->isa('HTTPHeader') };
coerce Header
- => as ArrayRef
- => to { HTTPHeader->new(array => $_[0]) }
- => as HashRef
- => to { HTTPHeader->new(hash => $_[0]) };
+ => from ArrayRef
+ => via { HTTPHeader->new(array => $_[0]) }
+ => from HashRef
+ => via { HTTPHeader->new(hash => $_[0]) };
Moose::Util::TypeConstraints::export_type_contstraints_as_functions();