0.35
* Class::MOP
- - non-generated accessors are no longer
- copied, but instead are aliased from
- the originals
+ - accessors are no longer generated, instead
+ they are aliased from the originals
+ - this means that the bootstrap will no longer
+ re-compiles accessors so as to keep the MOP
+ compile-time fast
+ - fixed tests to reflect
- added Class::MOP::Method (and its subclasses)
to the bootstrap
- adjusted tests for this
- added the Class::MOP::Instance attributes
to the bootstrap
- - bootstrap no longer re-compiles accessors
- so as to keep the MOP compile-time fast
* Class::MOP::Method
*** API CHANGE ***
Class::MOP::Class->meta->add_attribute(
Class::MOP::Attribute->new('$:attribute_metaclass' => (
- reader => 'attribute_metaclass',
+ reader => {
+ # NOTE:
+ # we just alias the original method
+ # rather than re-produce it here
+ 'attribute_metaclass' => \&Class::MOP::Class::attribute_metaclass
+ },
init_arg => ':attribute_metaclass',
default => 'Class::MOP::Attribute',
))
Class::MOP::Class->meta->add_attribute(
Class::MOP::Attribute->new('$:method_metaclass' => (
- reader => 'method_metaclass',
+ reader => {
+ # NOTE:
+ # we just alias the original method
+ # rather than re-produce it here
+ 'method_metaclass' => \&Class::MOP::Class::method_metaclass
+ },
init_arg => ':method_metaclass',
default => 'Class::MOP::Method',
))
Class::MOP::Attribute->meta->add_attribute(
Class::MOP::Attribute->new('accessor' => (
- reader => 'accessor',
- predicate => 'has_accessor',
+ reader => { 'accessor' => \&Class::MOP::Attribute::accessor },
+ predicate => { 'has_accessor' => \&Class::MOP::Attribute::has_accessor },
))
);
Class::MOP::Attribute->meta->add_attribute(
Class::MOP::Attribute->new('reader' => (
- reader => 'reader',
- predicate => 'has_reader',
+ reader => { 'reader' => \&Class::MOP::Attribute::reader },
+ predicate => { 'has_reader' => \&Class::MOP::Attribute::has_reader },
))
);
Class::MOP::Attribute->meta->add_attribute(
Class::MOP::Attribute->new('writer' => (
- reader => 'writer',
- predicate => 'has_writer',
+ reader => { 'writer' => \&Class::MOP::Attribute::writer },
+ predicate => { 'has_writer' => \&Class::MOP::Attribute::has_writer },
))
);
Class::MOP::Attribute->meta->add_attribute(
Class::MOP::Attribute->new('predicate' => (
- reader => 'predicate',
- predicate => 'has_predicate',
+ reader => { 'predicate' => \&Class::MOP::Attribute::predicate },
+ predicate => { 'has_predicate' => \&Class::MOP::Attribute::has_predicate },
))
);
Class::MOP::Attribute->meta->add_attribute(
Class::MOP::Attribute->new('clearer' => (
- reader => 'clearer',
- predicate => 'has_clearer',
+ reader => { 'clearer' => \&Class::MOP::Attribute::clearer },
+ predicate => { 'has_clearer' => \&Class::MOP::Attribute::has_clearer },
))
);
Class::MOP::Attribute->meta->add_attribute(
Class::MOP::Attribute->new('init_arg' => (
- reader => 'init_arg',
- predicate => 'has_init_arg',
+ reader => { 'init_arg' => \&Class::MOP::Attribute::init_arg },
+ predicate => { 'has_init_arg' => \&Class::MOP::Attribute::has_init_arg },
))
);
Class::MOP::Attribute->meta->add_attribute(
Class::MOP::Attribute->new('default' => (
# default has a custom 'reader' method ...
- predicate => 'has_default',
+ predicate => { 'has_default' => \&Class::MOP::Attribute::has_default },
))
);
Class::MOP::Method->meta->add_attribute(
Class::MOP::Attribute->new('body' => (
- reader => 'body'
+ reader => { 'body' => \&Class::MOP::Method::body },
))
);
# ... class
ok($class_mop_class_meta->get_attribute('%:attributes')->has_reader, '... Class::MOP::Class %:attributes has a reader');
-is(ref($class_mop_class_meta->get_attribute('%:attributes')->reader),
- 'HASH',
+is_deeply($class_mop_class_meta->get_attribute('%:attributes')->reader,
+ { 'get_attribute_map' => \&Class::MOP::Class::get_attribute_map },
'... Class::MOP::Class %:attributes\'s a reader is &get_attribute_map');
ok($class_mop_class_meta->get_attribute('%:attributes')->has_init_arg, '... Class::MOP::Class %:attributes has a init_arg');
'... Class::MOP::Class %:attributes\'s a default of {}');
ok($class_mop_class_meta->get_attribute('$:attribute_metaclass')->has_reader, '... Class::MOP::Class $:attribute_metaclass has a reader');
-is($class_mop_class_meta->get_attribute('$:attribute_metaclass')->reader,
- 'attribute_metaclass',
+is_deeply($class_mop_class_meta->get_attribute('$:attribute_metaclass')->reader,
+ { 'attribute_metaclass' => \&Class::MOP::Class::attribute_metaclass },
'... Class::MOP::Class $:attribute_metaclass\'s a reader is &attribute_metaclass');
ok($class_mop_class_meta->get_attribute('$:attribute_metaclass')->has_init_arg, '... Class::MOP::Class $:attribute_metaclass has a init_arg');
'... Class::MOP::Class $:attribute_metaclass\'s a default is Class::MOP:::Attribute');
ok($class_mop_class_meta->get_attribute('$:method_metaclass')->has_reader, '... Class::MOP::Class $:method_metaclass has a reader');
-is($class_mop_class_meta->get_attribute('$:method_metaclass')->reader,
- 'method_metaclass',
+is_deeply($class_mop_class_meta->get_attribute('$:method_metaclass')->reader,
+ { 'method_metaclass' => \&Class::MOP::Class::method_metaclass },
'... Class::MOP::Class $:method_metaclass\'s a reader is &method_metaclass');
ok($class_mop_class_meta->get_attribute('$:method_metaclass')->has_init_arg, '... Class::MOP::Class $:method_metaclass has a init_arg');