Made creating the immutable class lazy
Dave Rolsky [Tue, 2 Dec 2008 23:07:01 +0000 (23:07 +0000)]
lib/Class/MOP/Immutable.pm

index d680d8e..357cd75 100644 (file)
@@ -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'}             }