Moose->init_meta(%p);
return Moose::Util::MetaRole::apply_metaclass_roles(
- for_class => $p{for_class},
+ for => $p{for_class},
class_metaroles => {
class => ['MooseX::ClassAttribute::Role::Meta::Class'],
},
- role_metaroles => {
- role => ['MooseX::ClassAttribute::Role::Meta::Role'],
- },
+
+ # role_metaroles => {
+ # role => ['MooseX::ClassAttribute::Role::Meta::Role'],
+ # },
);
}
use strict;
use warnings;
-use MooseX::AttributeHelpers;
use MooseX::ClassAttribute::Role::Meta::Attribute;
use Scalar::Util qw( blessed );
+use namespace::autoclean;
use Moose::Role;
-has class_attribute_map => (
- metaclass => 'Collection::Hash',
- is => 'ro',
- isa => 'HashRef[Moose::Meta::Attribute]',
- provides => {
- set => '_add_class_attribute',
- exists => 'has_class_attribute',
- get => 'get_class_attribute',
- delete => '_remove_class_attribute',
- keys => 'get_class_attribute_list',
- },
- default => sub { {} },
- reader => 'get_class_attribute_map',
-);
+with 'MooseX::ClassAttribute::Role::Meta::Mixin::HasClassAttributes';
has _class_attribute_values => (
- metaclass => 'Collection::Hash',
- is => 'ro',
- isa => 'HashRef',
- provides => {
- get => 'get_class_attribute_value',
- set => 'set_class_attribute_value',
- exists => 'has_class_attribute_value',
- delete => 'clear_class_attribute_value',
+ traits => ['Hash'],
+ is => 'ro',
+ isa => 'HashRef',
+ handles => {
+ 'get_class_attribute_value' => 'get',
+ 'set_class_attribute_value' => 'set',
+ 'has_class_attribute_value' => 'exists',
+ 'clear_class_attribute_value' => 'delete',
},
- lazy => 1,
- default => sub { $_[0]->_class_attribute_values_hashref() },
+ lazy => 1,
+ default => sub { $_[0]->_class_attribute_values_hashref() },
+ init_arg => undef,
);
sub add_class_attribute {
. $self->inline_class_slot_access($name) . ')';
}
-no Moose::Role;
-
1;
__END__
--- /dev/null
+package MooseX::ClassAttribute::Role::Meta::Mixin::HasClassAttributes;
+
+use strict;
+use warnings;
+
+use namespace::autoclean;
+use Moose::Role;
+
+has _class_attribute_map => (
+ traits => ['Hash'],
+ is => 'ro',
+ isa => 'HashRef[Moose::Meta::Attribute]',
+ handles => {
+ '_add_class_attribute' => 'set',
+ 'has_class_attribute' => 'exists',
+ 'get_class_attribute' => 'get',
+ '_remove_class_attribute' => 'delete',
+ 'get_class_attribute_list' => 'keys',
+ },
+ default => sub { {} },
+ init_arg => undef,
+);
+
+sub get_class_attribute_map {
+ return $_[0]->_class_attribute_map();
+}
+
+1;
+++ /dev/null
-use strict;
-use warnings;
-
-use Test::More tests => 2;
-
-{
- package MyClass;
-
- use MooseX::ClassAttribute;
- use MooseX::AttributeHelpers;
-
- class_has counter =>
- ( metaclass => 'Counter',
- is => 'ro',
- provides => { inc => 'inc_counter',
- },
- );
-}
-
-is( MyClass->counter(), 0 );
-
-MyClass->inc_counter();
-is( MyClass->counter(), 1 );