Subject: | Overload modulus |
package MooseX::Types::TypeDecorator;
use overload
'%' => sub {
my ($self, $val) = @_;
$self->__type_constraint->assert_coerce($val);
};
This is perhaps not as super-fantastic as my other suggestion
(overloading smart match), but I still think it's quite cool. It allows:
use MooseX::Types::URI qw/Uri/;
my $uri = 'http://example.com/' % Uri;
Or even:
use MooseX::Types::URI qw/Uri/;
my $uri = <STDIN>;
chomp $uri;
$uri %= Uri;