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,
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;
use strict;
use warnings;
-use Test::More tests => 300;
+use Test::More tests => 302;
use Test::Exception;
use Class::MOP;
_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