our $VERSION = '0.04';
-## Attributes
-
-## the meta for the role package
+use base 'Class::MOP::Module';
-__PACKAGE__->meta->add_attribute('_role_meta' => (
- reader => '_role_meta',
- init_arg => ':role_meta'
-));
+## Attributes
## roles
## Methods
-sub new {
- my $class = shift;
- my %options = @_;
- $options{':role_meta'} = Moose::Meta::Class->initialize(
- $options{role_name},
- ':method_metaclass' => 'Moose::Meta::Role::Method'
- ) unless defined $options{':role_meta'} &&
- $options{':role_meta'}->isa('Moose::Meta::Class');
- my $self = $class->meta->new_object(%options);
- return $self;
-}
+sub method_metaclass { 'Moose::Meta::Role::Method' }
## subroles
## methods
-# NOTE:
-# we delegate to some role_meta methods for convience here
-# the Moose::Meta::Role is meant to be a read-only interface
-# to the underlying role package, if you want to manipulate
-# that, just use ->role_meta
-
-sub name { (shift)->_role_meta->name }
-sub version { (shift)->_role_meta->version }
-
-sub get_method { (shift)->_role_meta->get_method(@_) }
-sub find_method_by_name { (shift)->_role_meta->find_method_by_name(@_) }
-sub has_method { (shift)->_role_meta->has_method(@_) }
-sub alias_method { (shift)->_role_meta->alias_method(@_) }
+sub get_method { (shift)->Moose::Meta::Class::get_method(@_) }
+sub find_method_by_name { (shift)->Moose::Meta::Class::find_method_by_name(@_) }
+sub has_method { (shift)->Moose::Meta::Class::has_method(@_) }
+sub alias_method { (shift)->Moose::Meta::Class::alias_method(@_) }
sub get_method_list {
my ($self) = @_;
grep {
# but they do, so we need to switch Moose::Role
# and Moose to use Sub::Exporter to prevent this
!/^(meta|has|extends|blessed|confess|augment|inner|override|super|before|after|around|with|requires)$/
- } $self->_role_meta->get_method_list;
+ } $self->Moose::Meta::Class::get_method_list;
}
# ... however the items in statis (attributes & method modifiers)
# is probably fairly safe to assume that
# anon classes will only be used internally
# or by people who know what they are doing
- $other->_role_meta->remove_method($method_name)
- if $other->_role_meta->name =~ /__ANON__/;
+ $other->Moose::Meta::Class::remove_method($method_name)
+ if $other->name =~ /__ANON__/;
}
else {
next;
$other->add_role($self);
}
+my $anon_counter = 0;
+
sub combine {
my ($class, @roles) = @_;
- my $combined = $class->new(
- ':role_meta' => Moose::Meta::Class->create_anon_class()
- );
+ my $pkg_name = __PACKAGE__ . "::__ANON__::" . $anon_counter++;
+ eval "package " . $pkg_name . "; our \$VERSION = '0.00';";
+ die $@ if $@;
+
+ my $combined = $class->initialize($pkg_name);
foreach my $role (@roles) {
$role->apply($combined);
=over 4
+=item B<method_metaclass>
+
=item B<find_method_by_name>
=item B<get_method>