From: Dave Rolsky Date: Tue, 2 Dec 2008 23:07:01 +0000 (+0000) Subject: Made creating the immutable class lazy X-Git-Tag: 0.71_01~30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=76c20e30b6201d8bf5d233b83e782363b03ec8d2;p=gitmo%2FClass-MOP.git Made creating the immutable class lazy --- diff --git a/lib/Class/MOP/Immutable.pm b/lib/Class/MOP/Immutable.pm index d680d8e..357cd75 100644 --- a/lib/Class/MOP/Immutable.pm +++ b/lib/Class/MOP/Immutable.pm @@ -38,12 +38,6 @@ sub new { 'immutable_metaclass' => undef, ); - # NOTE: - # we initialize the immutable - # version of the metaclass here - # FIXME lazify - $self->create_immutable_metaclass; - return $self; } @@ -54,7 +48,14 @@ sub _new { bless $options, $class; } -sub immutable_metaclass { (shift)->{'immutable_metaclass'} } +sub immutable_metaclass { + my $self = shift; + + $self->create_immutable_metaclass unless $self->{'immutable_metaclass'}; + + return $self->{'immutable_metaclass'}; +} + sub metaclass { (shift)->{'metaclass'} } sub options { (shift)->{'options'} }