[ENHANCEMENTS]
- * It's now possible to tell the metaclass pragma to not install a 'meta'
- method into classes that use it. (doy)
+ * It's now possible to tell Class::MOP::Class->create and the metaclass
+ pragma to not install a 'meta' method into classes they manipulate. (doy)
[OTHER]
superclasses
attributes
methods
+ no_meta
version
authority
)};
if caller =~ /Class::MOP|metaclass/;
}
$class->initialize(ref($_[0]) || $_[0]);
- });
+ }) unless $options{no_meta};
$meta->superclasses(@{$options{superclasses}})
if exists $options{superclasses};
An optional array reference of L<Class::MOP::Attribute> objects.
+=item * no_meta
+
+If true, a C<meta> method will not be installed into the class.
+
=back
=item B<< Class::MOP::Class->create_anon_class(%options) >>
use Class::MOP;
{
- package Foo;
- use metaclass no_meta => 1;
+ {
+ package Foo;
+ use metaclass no_meta => 1;
+ }
+
+ my $meta = Class::MOP::class_of('Foo');
+ ok(!$meta->has_method('meta'), "no meta method was installed");
+ $meta->add_method(meta => sub { die 'META' });
+ lives_ok { $meta->find_method_by_name('meta') } "can do meta-level stuff";
+ lives_ok { $meta->make_immutable } "can do meta-level stuff";
+ lives_ok { $meta->class_precedence_list } "can do meta-level stuff";
}
-my $meta = Class::MOP::class_of('Foo');
-ok(!$meta->has_method('meta'), "no meta method was installed");
-$meta->add_method(meta => sub { die 'META' });
-lives_ok { $meta->find_method_by_name('meta') } "can do meta-level stuff";
-lives_ok { $meta->make_immutable } "can do meta-level stuff";
-lives_ok { $meta->class_precedence_list } "can do meta-level stuff";
+{
+ my $meta = Class::MOP::Class->create('Bar', no_meta => 1);
+ ok(!$meta->has_method('meta'), "no meta method was installed");
+ $meta->add_method(meta => sub { die 'META' });
+ lives_ok { $meta->find_method_by_name('meta') } "can do meta-level stuff";
+ lives_ok { $meta->make_immutable } "can do meta-level stuff";
+ lives_ok { $meta->class_precedence_list } "can do meta-level stuff";
+}
done_testing;