From: gfx Date: Sat, 10 Oct 2009 08:07:42 +0000 (+0900) Subject: Creates role_type in Mouse::Role::init_meta X-Git-Tag: 0.37_06~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9704fe9d256a2d4e4668beea554661c38ff63698;p=gitmo%2FMouse.git Creates role_type in Mouse::Role::init_meta --- diff --git a/lib/Mouse/Role.pm b/lib/Mouse/Role.pm index da5b302..0ae4917 100644 --- a/lib/Mouse/Role.pm +++ b/lib/Mouse/Role.pm @@ -109,19 +109,24 @@ sub excludes { } sub init_meta{ - my($class, %args) = @_; + shift; + my %args = @_; - my $for_class = $args{for_class} + my $class = $args{for_class} or Carp::confess("Cannot call init_meta without specifying a for_class"); my $metaclass = $args{metaclass} || 'Mouse::Meta::Role'; - my $meta = $metaclass->initialize($for_class); + my $meta = $metaclass->initialize($class); $meta->add_method(meta => sub{ $metaclass->initialize(ref($_[0]) || $_[0]); }); + # make a role type for each Mouse role + Mouse::Util::TypeConstraints::role_type($class) + unless Mouse::Util::TypeConstraints::find_type_constraint($class); + return $meta; }