Checking in changes prior to tagging of version 0.68.
[gitmo/Mouse.git] / lib / Mouse / Meta / Role.pm
index a408522..d3be7cd 100644 (file)
@@ -129,7 +129,8 @@ sub _apply_methods{
 }
 
 sub _apply_attributes{
-    my($role, $consumer, $args) = @_;
+    #my($role, $consumer, $args) = @_;
+    my($role, $consumer) = @_;
 
     for my $attr_name ($role->get_attribute_list) {
         next if $consumer->has_attribute($attr_name);
@@ -140,7 +141,9 @@ sub _apply_attributes{
 }
 
 sub _apply_modifiers{
-    my($role, $consumer, $args) = @_;
+    #my($role, $consumer, $args) = @_;
+    my($role, $consumer) = @_;
+
 
     if(my $modifiers = $role->{override_method_modifiers}){
         foreach my $method_name (keys %{$modifiers}){
@@ -149,13 +152,13 @@ sub _apply_modifiers{
     }
 
     for my $modifier_type (qw/before around after/) {
-        my $modifiers = $role->{"${modifier_type}_method_modifiers"}
+        my $table = $role->{"${modifier_type}_method_modifiers"}
             or next;
 
         my $add_modifier = "add_${modifier_type}_method_modifier";
 
-        foreach my $method_name (keys %{$modifiers}){
-            foreach my $code(@{ $modifiers->{$method_name} }){
+        while(my($method_name, $modifiers) = each %{$table}){
+            foreach my $code(@{ $modifiers }){
                 next if $consumer->{"_applied_$modifier_type"}{$method_name, $code}++; # skip applied modifiers
                 $consumer->$add_modifier($method_name => $code);
             }
@@ -165,12 +168,13 @@ sub _apply_modifiers{
 }
 
 sub _append_roles{
-    my($role, $consumer, $args) = @_;
+    #my($role, $consumer, $args) = @_;
+    my($role, $consumer) = @_;
 
-    my $roles = ($args->{_to} eq 'role') ? $consumer->get_roles : $consumer->roles;
+    my $roles = $consumer->{roles};
 
     foreach my $r($role, @{$role->get_roles}){
-        if(!$consumer->does_role($r->name)){
+        if(!$consumer->does_role($r)){
             push @{$roles}, $r;
         }
     }
@@ -234,7 +238,7 @@ sub apply {
     if(defined $instance){ # Application::ToInstance
         # rebless instance
         bless $instance, $consumer->name;
-        $consumer->_initialize_object($instance, $instance);
+        $consumer->_initialize_object($instance, $instance, 1);
     }
 
     return;
@@ -242,7 +246,7 @@ sub apply {
 
 
 sub combine {
-    my($role_class, @role_specs) = @_;
+    my($self, @role_specs) = @_;
 
     require 'Mouse/Meta/Role/Composite.pm'; # we don't want to create its namespace
 
@@ -255,37 +259,13 @@ sub combine {
     return $composite;
 }
 
-sub add_before_method_modifier {
-    my ($self, $method_name, $method) = @_;
-
-    push @{ $self->{before_method_modifiers}{$method_name} ||= [] }, $method;
-    return;
-}
-sub add_around_method_modifier {
-    my ($self, $method_name, $method) = @_;
+sub add_before_method_modifier;
+sub add_around_method_modifier;
+sub add_after_method_modifier;
 
-    push @{ $self->{around_method_modifiers}{$method_name} ||= [] }, $method;
-    return;
-}
-sub add_after_method_modifier {
-    my ($self, $method_name, $method) = @_;
-
-    push @{ $self->{after_method_modifiers}{$method_name} ||= [] }, $method;
-    return;
-}
-
-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 get_before_method_modifiers;
+sub get_around_method_modifiers;
+sub get_after_method_modifiers;
 
 sub add_override_method_modifier{
     my($self, $method_name, $method) = @_;
@@ -312,6 +292,8 @@ sub does_role {
     (defined $role_name)
         || $self->throw_error("You must supply a role name to look for");
 
+    $role_name = $role_name->name if ref $role_name;
+
     # if we are it,.. then return true
     return 1 if $role_name eq $self->name;
     # otherwise.. check our children
@@ -330,7 +312,12 @@ Mouse::Meta::Role - The Mouse Role metaclass
 
 =head1 VERSION
 
-This document describes Mouse version 0.50_03
+This document describes Mouse version 0.68
+
+=head1 DESCRIPTION
+
+This class is a meta object protocol for Mouse roles,
+which is a subset of Moose::Meta:::Role.
 
 =head1 SEE ALSO