From: Jesse Luehrs Date: Thu, 10 Sep 2009 02:03:53 +0000 (-0500) Subject: don't break the semantics of _immutable_options so much X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f0bcd5b530b03f977c5e325b127ab10cba902c3;p=gitmo%2FClass-MOP.git don't break the semantics of _immutable_options so much --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index a0b4e39..6a6293b 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -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; diff --git a/t/010_self_introspection.t b/t/010_self_introspection.t index bcc6335..72026d1 100644 --- a/t/010_self_introspection.t +++ b/t/010_self_introspection.t @@ -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