-
package Moose::Meta::Role;
use strict;
use warnings;
use metaclass;
+use Class::Load qw(load_class);
use Scalar::Util 'blessed';
use Carp 'confess';
use Devel::GlobalDestruction 'in_global_destruction';
# NOTE:
# since roles are lazy, we hold all the attributes
-# of the individual role in 'statis' until which
+# of the individual role in 'stasis' until which
# time when it is applied to a class. This means
# keeping a lot of things in hash maps, so we are
# using a little of that meta-programmin' magic
# create the attribute
$META->add_attribute($action->{name} => (
reader => $attr_reader,
- default => sub { {} }
+ default => sub { {} },
+ Class::MOP::_definition_context(),
));
# create some helper methods
'method_metaclass',
reader => 'method_metaclass',
default => 'Moose::Meta::Role::Method',
+ Class::MOP::_definition_context(),
);
$META->add_attribute(
'required_method_metaclass',
reader => 'required_method_metaclass',
default => 'Moose::Meta::Role::Method::Required',
+ Class::MOP::_definition_context(),
);
$META->add_attribute(
'conflicting_method_metaclass',
reader => 'conflicting_method_metaclass',
default => 'Moose::Meta::Role::Method::Conflicting',
+ Class::MOP::_definition_context(),
);
$META->add_attribute(
'application_to_class_class',
reader => 'application_to_class_class',
default => 'Moose::Meta::Role::Application::ToClass',
+ Class::MOP::_definition_context(),
);
$META->add_attribute(
'application_to_role_class',
reader => 'application_to_role_class',
default => 'Moose::Meta::Role::Application::ToRole',
+ Class::MOP::_definition_context(),
);
$META->add_attribute(
'application_to_instance_class',
reader => 'application_to_instance_class',
default => 'Moose::Meta::Role::Application::ToInstance',
+ Class::MOP::_definition_context(),
);
$META->add_attribute(
'applied_attribute_metaclass',
reader => 'applied_attribute_metaclass',
default => 'Moose::Meta::Attribute',
+ Class::MOP::_definition_context(),
);
# More or less copied from Moose::Meta::Class
# create the attribute ...
$META->add_attribute("${modifier_type}_method_modifiers" => (
reader => $attr_reader,
- default => sub { {} }
+ default => sub { {} },
+ Class::MOP::_definition_context(),
));
# and some helper methods ...
$META->add_attribute('override_method_modifiers' => (
reader => 'get_override_method_modifiers_map',
- default => sub { {} }
+ default => sub { {} },
+ Class::MOP::_definition_context(),
));
# NOTE:
$META->add_attribute('roles' => (
reader => 'get_roles',
- default => sub { [] }
+ default => sub { [] },
+ Class::MOP::_definition_context(),
));
sub add_role {
$application_class = $self->application_to_instance_class;
}
- Class::MOP::load_class($application_class);
-
- my $deprecation_check = 0;
-
- if ( exists $args{excludes} && !exists $args{'-excludes'} ) {
- $args{'-excludes'} = delete $args{excludes};
- $deprecation_check = 1;
- }
- if ( exists $args{alias} && !exists $args{'-alias'} ) {
- $args{'-alias'} = delete $args{alias};
- $deprecation_check = 1;
- }
-
- if ( $deprecation_check ) {
- Moose::Deprecated::deprecated(
- feature => 'alias or excludes',
- message =>
- 'The alias and excludes options for role application'.
- ' have been renamed -alias and -excludes'.
- " (${\$other->name} is consuming ${\$self->name}".
- " - do you need to upgrade ${\$other->name}?).".
- ' This will be an error in Moose 2.0200.'
- );
- }
+ load_class($application_class);
if ( exists $args{'-excludes'} ) {
# I wish we had coercion here :)
=back
+=head2 Overload introspection and creation
+
+The methods for dealing with a role's overloads are all identical in API
+and behavior to the same methods in L<Class::MOP::Class>. Note that these are
+not particularly useful (yet), because overloads do not participate in role
+composition.
+
+=over 4
+
+=item B<< $metarole->is_overloaded >>
+
+=item B<< $metarole->get_overloaded_operator($op) >>
+
+=item B<< $metarole->has_overloaded_operator($op) >>
+
+=item B<< $metarole->get_overload_list >>
+
+=item B<< $metarole->get_all_overloaded_operators >>
+
+=item B<< $metarole->add_overloaded_operator($op, $impl) >>
+
+=item B<< $metarole->remove_overloaded_operator($op) >>
+
+=back
+
=head2 Required methods
=over 4