use Scalar::Util 'blessed';
use Carp 'confess';
-our $VERSION = '0.72_01';
+our $VERSION = '0.75_01';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
}) if exists $methods->{remove};
}
+$META->add_attribute(
+ 'method_metaclass',
+ reader => 'method_metaclass',
+ default => 'Moose::Meta::Role::Method',
+);
+
## some things don't always fit, so they go here ...
sub add_attribute {
$self->get_attribute_map->{$name} = $attr_desc;
}
-# DEPRECATED
-# sub _clean_up_required_methods {
-# my $self = shift;
-# foreach my $method ($self->get_required_method_list) {
-# $self->remove_required_methods($method)
-# if $self->has_method($method);
-# }
-# }
-
## ------------------------------------------------------------------
## method modifiers
## ------------------------------------------------------------------
## subroles
-__PACKAGE__->meta->add_attribute('roles' => (
+$META->add_attribute('roles' => (
reader => 'get_roles',
default => sub { [] }
));
## ------------------------------------------------------------------
## methods
-sub method_metaclass { 'Moose::Meta::Role::Method' }
-
sub get_method_map {
my $self = shift;
$map->{$symbol}->body == $code;
my ($pkg, $name) = Class::MOP::get_code_info($code);
+ my $meta = Class::MOP::class_of($pkg);
- if ($pkg->can('meta')
- # NOTE:
- # we don't know what ->meta we are calling
- # here, so we need to be careful cause it
- # just might blow up at us, or just complain
- # loudly (in the case of Curses.pm) so we
- # just be a little overly cautious here.
- # - SL
- && eval { no warnings; blessed($pkg->meta) } # FIXME calls meta
- && $pkg->meta->isa('Moose::Meta::Role')) {
- my $role = $pkg->meta->name;
+ if ($meta && $meta->isa('Moose::Meta::Role')) {
+ my $role = $meta->name;
next unless $self->does_role($role);
}
else {
}
sub alias_method {
+ Carp::cluck("The alias_method method is deprecated. Use add_method instead.\n");
+
my $self = shift;
$self->add_method(@_);
my (@roles, %role_params);
while (@role_specs) {
my ($role, $params) = @{ splice @role_specs, 0, 1 };
- push @roles => $role->meta;
+ push @roles => Class::MOP::class_of($role);
next unless defined $params;
$role_params{$role} = $params;
}
The options are passed directly to the constructor for the appropriate
L<Moose::Meta::Role::Application> subclass.
+Note that this will apply the role even if the C<$thing> in question already
+C<does> this role. L<Moose::Util/does_role> is a convenient wrapper for
+finding out if role application is necessary.
+
=back
=head2 Roles and other roles