our
$VERSION
=
'2.2207'
;
__PACKAGE__->meta->add_attribute(
'name'
=> (
reader
=>
'name'
,
Class::MOP::_definition_context(),
));
__PACKAGE__->meta->add_attribute(
'_methods'
=> (
reader
=>
'_method_map'
,
default
=>
sub
{ {} },
Class::MOP::_definition_context(),
));
__PACKAGE__->meta->add_attribute(
'_overloads'
=> (
reader
=>
'_overload_map'
,
default
=>
sub
{ {} },
Class::MOP::_definition_context(),
));
__PACKAGE__->meta->add_attribute(
'_overload_fallback'
=> (
accessor
=>
'_overload_fallback'
,
Class::MOP::_definition_context(),
));
__PACKAGE__->meta->add_attribute(
'application_role_summation_class'
,
reader
=>
'application_role_summation_class'
,
default
=>
'Moose::Meta::Role::Application::RoleSummation'
,
Class::MOP::_definition_context(),
);
sub
new {
my
(
$class
,
%params
) =
@_
;
foreach
( @{
$params
{roles}} ) {
unless
(
$_
->isa(
'Moose::Meta::Role'
) ) {
throw_exception(
RolesListMustBeInstancesOfMooseMetaRole
=>
params
=> \
%params
,
role
=>
$_
,
class
=>
$class
);
}
}
my
@composition_roles
=
map
{
$_
->composition_class_roles
} @{
$params
{roles} };
if
(
@composition_roles
) {
my
$meta
= Moose::Meta::Class->create_anon_class(
superclasses
=> [
$class
],
roles
=> [
@composition_roles
],
cache
=> 1,
);
$class
=
$meta
->name;
}
$params
{name} ||= (
join
"|"
=>
map
{
$_
->name } @{
$params
{roles}});
$class
->_new(\
%params
);
}
sub
is_anon { 0 }
sub
add_method {
my
(
$self
,
$method_name
,
$method
) =
@_
;
unless
(
defined
$method_name
&&
$method_name
) {
throw_exception(
MustDefineAMethodName
=>
instance
=>
$self
);
}
my
$body
;
if
(blessed(
$method
)) {
$body
=
$method
->body;
if
(
$method
->package_name ne
$self
->name) {
$method
=
$method
->clone(
package_name
=>
$self
->name,
name
=>
$method_name
)
if
$method
->can(
'clone'
);
}
}
else
{
$body
=
$method
;
$method
=
$self
->wrap_method_body(
body
=>
$body
,
name
=>
$method_name
);
}
$self
->_method_map->{
$method_name
} =
$method
;
}
sub
get_method_list {
my
$self
=
shift
;
return
keys
%{
$self
->_method_map };
}
sub
_get_local_methods {
my
$self
=
shift
;
return
values
%{
$self
->_method_map };
}
sub
has_method {
my
(
$self
,
$method_name
) =
@_
;
return
exists
$self
->_method_map->{
$method_name
};
}
sub
get_method {
my
(
$self
,
$method_name
) =
@_
;
return
$self
->_method_map->{
$method_name
};
}
sub
is_overloaded {
my
(
$self
) =
@_
;
return
keys
%{
$self
->_overload_map };
}
sub
add_overloaded_operator {
my
(
$self
,
$op_name
,
$overload
) =
@_
;
unless
(
defined
$op_name
&&
$op_name
) {
throw_exception(
'MustDefineAnOverloadOperator'
,
instance
=>
$self
,
);
}
$self
->_overload_map->{
$op_name
} =
$overload
;
}
sub
get_overload_fallback_value {
my
(
$self
) =
@_
;
return
$self
->_overload_fallback;
}
sub
set_overload_fallback_value {
my
$self
=
shift
;
$self
->_overload_fallback(
shift
);
}
sub
get_all_overloaded_operators {
my
(
$self
,
$method_name
) =
@_
;
return
values
%{
$self
->_overload_map };
}
sub
apply_params {
my
(
$self
,
$role_params
) =
@_
;
Moose::Util::_load_user_class(
$self
->application_role_summation_class);
$self
->application_role_summation_class->new(
role_params
=>
$role_params
,
)->apply(
$self
);
return
$self
;
}
sub
reinitialize {
my
(
$class
,
$old_meta
,
@args
) =
@_
;
throw_exception(
CannotInitializeMooseMetaRoleComposite
=>
old_meta
=>
$old_meta
,
args
=> \
@args
,
role_composite
=>
$class
)
if
!blessed
$old_meta
|| !
$old_meta
->isa(
'Moose::Meta::Role::Composite'
);
my
%existing_classes
=
map
{
$_
=>
$old_meta
->
$_
() }
qw(
application_role_summation_class
)
;
return
$old_meta
->meta->clone_object(
$old_meta
,
%existing_classes
,
@args
);
}
1;