Browse files

Stop pretending the created classes are anonymous

They closed over their own metaclass, so they weren't being cleaned up anyway.
Also debugging was shit as all the instances referenced the metaclass as well.
  • Loading branch information...
1 parent a1a3522 commit b414a2b88c388a839abaf84571e1a898401a48c7 @rafl rafl committed with May 12, 2010
Showing with 8 additions and 2 deletions.
  1. +4 −0 Changes
  2. +4 −2 lib/MooseX/Traits/Util.pm
View
4 Changes
@@ -1,3 +1,7 @@
+ - Stop pretending the created classes are anonymous.
+ They used to close over their own metaclass, so they were never
+ cleaned up anyway and only made debugging unnecessarily hard as
+ all instances referenced the metaclass as well.
- Require newer version of MX::Role::Parameterized in the parameterized
role test. (RT#49873).
View
6 lib/MooseX/Traits/Util.pm
@@ -55,6 +55,8 @@ sub resolve_traits {
} @traits;
}
+my $anon_serial = 0;
+
sub new_class_with_traits {
my ($class, @traits) = @_;
@@ -63,12 +65,12 @@ sub new_class_with_traits {
my $meta;
@traits = resolve_traits($class, @traits);
if (@traits) {
- $meta = $class->meta->create_anon_class(
+ $meta = $class->meta->create(
+ join(q{::} => 'MooseX::Traits::__ANON__::SERIAL', ++$anon_serial),
superclasses => [ $class->meta->name ],
roles => \@traits,
cache => 1,
);
- $meta->add_method('meta' => sub { $meta });
}
# if no traits were given just return the class meta

0 comments on commit b414a2b

Please sign in to comment.