X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FRole.pm;h=4c56868e7915759d4449b85e1087c5008f34bc38;hp=33350cc0ddf01859bb1a2e3178cd9eff5550e338;hb=2b68f76d78d96325821e9a6360c3639f8c5637df;hpb=bc69ee88207ce5c53f5c02dbd44cfabfbe6bae70 diff --git a/lib/Mouse/Role.pm b/lib/Mouse/Role.pm index 33350cc..4c56868 100644 --- a/lib/Mouse/Role.pm +++ b/lib/Mouse/Role.pm @@ -1,11 +1,14 @@ package Mouse::Role; -use Mouse::Util qw(not_supported); # enables strict and warnings +use Mouse::Exporter; # enables strict and warnings -use Carp (); -use Scalar::Util (); +our $VERSION = '0.40_03'; +use Carp qw(confess); +use Scalar::Util qw(blessed); + +use Mouse::Util qw(not_supported); +use Mouse::Meta::Role; use Mouse (); -use Mouse::Exporter; Mouse::Exporter->setup_import_methods( as_is => [qw( @@ -22,6 +25,18 @@ Mouse::Exporter->setup_import_methods( ], ); +# XXX: for backward compatibility +our @EXPORT = qw( + extends with + has + before after around + override super + augment inner + + requires excludes + + blessed confess +); sub before { my $meta = Mouse::Meta::Role->initialize(scalar caller); @@ -97,19 +112,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; } @@ -121,6 +141,10 @@ __END__ Mouse::Role - The Mouse Role +=head1 VERSION + +This document describes Mouse version 0.40_03 + =head1 SYNOPSIS package MyRole;