From: Graham Knop Date: Mon, 15 Jul 2013 01:48:22 +0000 (-0400) Subject: add comments explaining rationale for handling of requires in create_class_with_roles X-Git-Tag: v1.003000~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=76b67e35685e2c873b9b2d6f63dd843b94bd9e7a;hp=d08f8b3a4538da568c97c9ff4af826c8765ca30f;p=gitmo%2FRole-Tiny.git add comments explaining rationale for handling of requires in create_class_with_roles --- diff --git a/lib/Role/Tiny.pm b/lib/Role/Tiny.pm index 751527d..7bfe4be 100644 --- a/lib/Role/Tiny.pm +++ b/lib/Role/Tiny.pm @@ -135,8 +135,6 @@ sub create_class_with_roles { require MRO::Compat; } - my @composable = map $me->_composable_package_for($_), reverse @roles; - my $composite_info = $me->_composite_info_for(@roles); my %conflicts = %{$composite_info->{conflicts}}; if (keys %conflicts) { @@ -150,6 +148,12 @@ sub create_class_with_roles { die $fail; } + my @composable = map $me->_composable_package_for($_), reverse @roles; + + # some methods may not exist in the role, but get generated by + # _composable_package_for (Moose accessors via Moo). filter out anything + # provided by the composable packages, excluding the subs we generated to + # make modifiers work. my @requires = grep { my $method = $_; !grep $_->can($method) && !$COMPOSED{role}{$_}{modifiers_only}{$method}, @@ -250,7 +254,7 @@ sub _composable_package_for { return $composed_name if $COMPOSED{role}{$composed_name}; $me->_install_methods($composed_name, $role); my $base_name = $composed_name.'::_BASE'; - # force stash to exist + # force stash to exist so ->can doesn't complain _getstash($base_name); # Not using _getglob, since setting @ISA via the typeglob breaks # inheritance on 5.10.0 if the stash has previously been accessed an