From: Shawn M Moore Date: Tue, 17 Jun 2008 03:27:20 +0000 (+0000) Subject: Begin actually filling out Mouse::Meta::Role X-Git-Tag: 0.19~306 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=acf0f6434b244fd3141b43ace9d8d9a011b2b20b;p=gitmo%2FMouse.git Begin actually filling out Mouse::Meta::Role --- diff --git a/lib/Mouse/Meta/Role.pm b/lib/Mouse/Meta/Role.pm index 181578a..936f172 100644 --- a/lib/Mouse/Meta/Role.pm +++ b/lib/Mouse/Meta/Role.pm @@ -3,6 +3,32 @@ package Mouse::Meta::Role; use strict; use warnings; +do { + my %METACLASS_CACHE; + + # because Mouse doesn't introspect existing classes, we're forced to + # only pay attention to other Mouse classes + sub _metaclass_cache { + my $class = shift; + my $name = shift; + return $METACLASS_CACHE{$name}; + } + + sub initialize { + my $class = shift; + my $name = shift; + $METACLASS_CACHE{$name} = $class->new(name => $name) + if !exists($METACLASS_CACHE{$name}); + return $METACLASS_CACHE{$name}; + } +}; + +sub new { + my $class = shift; + my %args = @_; + + bless \%args, $class; +} 1;