don't break the semantics of _immutable_options so much attic/save_immutable_options
Jesse Luehrs [Thu, 10 Sep 2009 02:03:53 +0000 (21:03 -0500)]
lib/Class/MOP/Class.pm
t/010_self_introspection.t

index a0b4e39..6a6293b 100644 (file)
@@ -936,10 +936,10 @@ sub is_pristine {
 sub is_mutable   { 1 }
 sub is_immutable { 0 }
 
-sub _immutable_options {
-    my ( $self, @args ) = @_;
+sub _default_immutable_options {
+    my ( $self ) = @_;
 
-    $self->{_immutable_options} ||= {
+    return (
         inline_accessors   => 1,
         inline_constructor => 1,
         inline_destructor  => 0,
@@ -948,20 +948,22 @@ sub _immutable_options {
         constructor_name   => $self->constructor_name,
         constructor_class  => $self->constructor_class,
         destructor_class   => $self->destructor_class,
-    };
-    $self->{_immutable_options} = {
-        %{ $self->{_immutable_options} },
-        @args,
-    };
+    );
+}
+sub _immutable_options {
+    my ( $self, @args ) = @_;
 
-    return %{ $self->{_immutable_options} };
+    return @args;
 }
 
 sub make_immutable {
     my ( $self, @args ) = @_;
 
     if ( $self->is_mutable ) {
-        $self->_immutable_options(@args);
+        $self->{_immutable_options} ||= { $self->_default_immutable_options };
+        $self->{_immutable_options} = {
+            $self->_immutable_options( %{ $self->{_immutable_options} }, @args )
+        };
         $self->_initialize_immutable;
         $self->_rebless_as_immutable;
         return $self;
index bcc6335..72026d1 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 300;
+use Test::More tests => 302;
 use Test::Exception;
 
 use Class::MOP;
@@ -94,7 +94,7 @@ my @class_mop_class_methods = qw(
     _initialize_immutable _install_inlined_code _inlined_methods
     _add_inlined_method _inline_accessors _inline_constructor
     _inline_destructor _immutable_options _rebless_as_immutable
-    _rebless_as_mutable _remove_inlined_code
+    _rebless_as_mutable _remove_inlined_code _default_immutable_options
 
     _immutable_metaclass
     immutable_trait constructor_name constructor_class destructor_class