Skip to content

Commit

Permalink
Stop pretending the created classes are anonymous
Browse files Browse the repository at this point in the history
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
rafl committed May 12, 2010
1 parent 991ba2b commit a776924
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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).

Expand Down
6 changes: 4 additions & 2 deletions lib/MooseX/Traits/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ sub resolve_traits {
} @traits;
}

my $anon_serial = 0;

sub new_class_with_traits {
my ($class, @traits) = @_;

Expand All @@ -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
Expand Down

0 comments on commit a776924

Please sign in to comment.