From: Stevan Little Date: Tue, 11 Mar 2008 18:51:23 +0000 (+0000) Subject: tweaking formatting to match existing tests and code, also change log stuff X-Git-Tag: 0_55~284 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6d5cbd2b637d672d74ad86d5309580f142ee3439;p=gitmo%2FMoose.git tweaking formatting to match existing tests and code, also change log stuff --- diff --git a/Changes b/Changes index e9c8ed9..862ecbe 100644 --- a/Changes +++ b/Changes @@ -20,6 +20,9 @@ Revision history for Perl extension Moose * Moose::Meta::Class - added ->create method which now supports roles (thanks to jrockway) - added tests for this + - added ->create_anon_class which now supports roles and caching of + the results (thanks to jrockway) + - added tests for this * Moose::Util::TypeConstraints - it is now possible to make anon-enums by passing 'enum' an diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 38b077d..34ff29d 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -53,25 +53,21 @@ sub create_anon_class { my ($self, %options) = @_; my $cache_ok = delete $options{cache}; - - my @superclasses = sort @{$options{superclasses} || []}; - my @roles = sort @{$options{roles} || []}; # something like Super::Class|Super::Class::2=Role|Role::1 my $cache_key = join '=' => ( - join('|', @superclasses), - join('|', @roles), + join('|', sort @{$options{superclasses} || []}), + join('|', sort @{$options{roles} || []}), ); - if($cache_ok && defined $ANON_CLASSES{$cache_key}){ + if ($cache_ok && defined $ANON_CLASSES{$cache_key}) { return $ANON_CLASSES{$cache_key}; } my $new_class = $self->SUPER::create_anon_class(%options); - if($cache_ok){ - $ANON_CLASSES{$cache_key} = $new_class; - } + $ANON_CLASSES{$cache_key} = $new_class + if $cache_ok; return $new_class; } diff --git a/t/010_basics/013_create.t b/t/010_basics/013_create.t index 84ddee6..8fbafe7 100644 --- a/t/010_basics/013_create.t +++ b/t/010_basics/013_create.t @@ -1,5 +1,8 @@ +#!/usr/bin/perl + use strict; use warnings; + use Test::More tests => 10; use Test::Exception; diff --git a/t/010_basics/014_create_anon.t b/t/010_basics/014_create_anon.t index 924c696..d989455 100644 --- a/t/010_basics/014_create_anon.t +++ b/t/010_basics/014_create_anon.t @@ -1,5 +1,8 @@ +#!/usr/bin/perl + use strict; use warnings; + use Test::More tests => 11; BEGIN {