Checking in changes prior to tagging of version 0.40_08. Changelog diff is:
[gitmo/Mouse.git] / lib / Mouse / Meta / Role.pm
index d10023c..97d2d64 100644 (file)
@@ -4,17 +4,17 @@ use Mouse::Util qw(:meta not_supported english_list); # enables strict and warni
 use Mouse::Meta::Module;
 our @ISA = qw(Mouse::Meta::Module);
 
-sub method_metaclass(){ 'Mouse::Meta::Role::Method' } # required for get_method()
+sub method_metaclass;
 
 sub _construct_meta {
     my $class = shift;
 
     my %args  = @_;
 
-    $args{methods}          ||= {};
-    $args{attributes}       ||= {};
-    $args{required_methods} ||= [];
-    $args{roles}            ||= [];
+    $args{methods}          = {};
+    $args{attributes}       = {};
+    $args{required_methods} = [];
+    $args{roles}            = [];
 
     my $self = bless \%args, ref($class) || $class;
     if($class ne __PACKAGE__){
@@ -186,10 +186,10 @@ sub apply {
 
     my $instance;
 
-    if(Mouse::Util::TypeConstraints::_is_a_metaclass($applicant)){  # Application::ToClass
+    if(Mouse::Util::is_a_metaclass($applicant)){  # Application::ToClass
         $args{_to} = 'class';
     }
-    elsif(Mouse::Util::TypeConstraints::_is_a_metarole($applicant)){ # Application::ToRole
+    elsif(Mouse::Util::is_a_metarole($applicant)){ # Application::ToRole
         $args{_to} = 'role';
     }
     else{                                       # Appplication::ToInstance
@@ -255,27 +255,36 @@ sub combine {
     return $composite;
 }
 
-for my $modifier_type (qw/before after around/) {
+sub add_before_method_modifier {
+    my ($self, $method_name, $method) = @_;
 
-    my $modifier = "${modifier_type}_method_modifiers";
-
-    my $add_method_modifier =  sub {
-        my ($self, $method_name, $method) = @_;
-
-        push @{ $self->{$modifier}->{$method_name} ||= [] }, $method;
-        return;
-    };
+    push @{ $self->{before_method_modifiers}{$method_name} ||= [] }, $method;
+    return;
+}
+sub add_around_method_modifier {
+    my ($self, $method_name, $method) = @_;
 
-    my $get_method_modifiers = sub {
-        my ($self, $method_name) = @_;
-        return @{ $self->{$modifier}->{$method_name} ||= [] }
-    };
+    push @{ $self->{around_method_modifiers}{$method_name} ||= [] }, $method;
+    return;
+}
+sub add_after_method_modifier {
+    my ($self, $method_name, $method) = @_;
 
-    no strict 'refs';
-    *{ 'add_' . $modifier_type . '_method_modifier'  } = $add_method_modifier;
-    *{ 'get_' . $modifier_type . '_method_modifiers' } = $get_method_modifiers;
+    push @{ $self->{after_method_modifiers}{$method_name} ||= [] }, $method;
+    return;
+}
 
-    # has_${modifier_type}_method_modifiers is moved into t::lib::Test::Mouse
+sub get_before_method_modifiers {
+    my ($self, $method_name) = @_;
+    return @{ $self->{before_method_modifiers}{$method_name} ||= [] }
+}
+sub get_around_method_modifiers {
+    my ($self, $method_name) = @_;
+    return @{ $self->{around_method_modifiers}{$method_name} ||= [] }
+}
+sub get_after_method_modifiers {
+    my ($self, $method_name) = @_;
+    return @{ $self->{after_method_modifiers}{$method_name} ||= [] }
 }
 
 sub add_override_method_modifier{
@@ -321,7 +330,7 @@ Mouse::Meta::Role - The Mouse Role metaclass
 
 =head1 VERSION
 
-This document describes Mouse version 0.40_01
+This document describes Mouse version 0.40_08
 
 =head1 SEE ALSO