- Some level of attributes and methods for both classes and roles
- Required methods in roles
- Method modifiers in roles (they're already applied in classes)
+ - Type constraints
0.009014 - 2012-03-29
- Split Role::Tiny out into its own dist
use strictures 1;
use Moo::_Utils;
+our %TYPE_MAP;
+
sub import { inject_all() }
sub inject_all {
foreach my $name (keys %$attr_specs) {
my %spec = %{$attr_specs->{$name}};
$spec{is} = 'ro' if $spec{is} eq 'lazy';
+ if (my $isa = $spec{isa}) {
+ $spec{isa} = do {
+ if (my $mapped = $TYPE_MAP{$isa}) {
+ _load_module($mapped->[1]) if $mapped->[1];
+ Moose::Util::TypeConstraints::find_type_constraint($mapped->[0])
+ } else {
+ Moose::Meta::TypeConstraint->new(
+ constraint => sub { eval { &$isa; 1 } }
+ );
+ }
+ };
+ }
push @attrs, $meta->add_attribute($name => %spec);
}
}