use metaclass;
use Carp 'confess';
-use Scalar::Util 'blessed', 'reftype';
+use Scalar::Util 'blessed';
-our $VERSION = '0.13';
+our $VERSION = '0.56';
our $AUTHORITY = 'cpan:STEVAN';
use Moose::Meta::Class;
my $role_name = $self->name;
my $method_metaclass = $self->method_metaclass;
- foreach my $symbol ($self->list_all_package_symbols('CODE')) {
+ my %all_code = $self->get_all_package_symbols('CODE');
- my $code = $self->get_package_symbol('&' . $symbol);
+ foreach my $symbol (keys %all_code) {
+ my $code = $all_code{$symbol};
my ($pkg, $name) = Class::MOP::get_code_info($code);
next unless $self->does_role($role);
}
else {
- next if ($pkg || '') ne $role_name ||
- (($name || '') ne '__ANON__' && ($pkg || '') ne $role_name);
+ # NOTE:
+ # in 5.10 constant.pm the constants show up
+ # as being in the right package, but in pre-5.10
+ # they show up as constant::__ANON__ so we
+ # make an exception here to be sure that things
+ # work as expected in both.
+ # - SL
+ unless ($pkg eq 'constant' && $name eq '__ANON__') {
+ next if ($pkg || '') ne $role_name ||
+ (($name || '') ne '__ANON__' && ($pkg || '') ne $role_name);
+ }
}
$map->{$symbol} = $method_metaclass->wrap(
|| confess "You must define a method name";
my $body = (blessed($method) ? $method->body : $method);
- ('CODE' eq (reftype($body) || ''))
+ ('CODE' eq ref($body))
|| confess "Your code block must be a CODE reference";
- $self->add_package_symbol("&${method_name}" => $body);
+ $self->add_package_symbol(
+ { sigil => '&', type => 'CODE', name => $method_name },
+ $body
+ );
}
## ------------------------------------------------------------------