sub immutable_transformer { $_[0]->{immutable_transformer} }
sub _set_immutable_transformer { $_[0]->{immutable_transformer} = $_[1] }
+sub make_immutable {
+ my $self = shift;
+
+ return if $self->is_immutable;
+
+ my $transformer = $self->immutable_transformer
+ || $self->_make_immutable_transformer(@_);
+
+ $self->_set_immutable_transformer($transformer);
+
+ $transformer->make_metaclass_immutable;
+}
+
{
my %Default_Immutable_Options = (
read_only => [qw/superclasses/],
cannot_call => [
- qw/
+ qw(
add_method
alias_method
remove_method
add_attribute
remove_attribute
remove_package_symbol
- /
+ )
],
memoize => {
class_precedence_list => 'ARRAY',
},
);
- sub make_immutable {
- my $self = shift;
-
- return if $self->is_immutable;
-
- my $transformer = $self->immutable_transformer
- || Class::MOP::Immutable->new(
- $self,
- %Default_Immutable_Options,
- @_
- );
+ sub _default_immutable_transformer_options {
+ return %Default_Immutable_Options;
+ }
+}
- $self->_set_immutable_transformer($transformer);
+sub _make_immutable_transformer {
+ my $self = shift;
- $transformer->make_metaclass_immutable;
- }
+ Class::MOP::Immutable->new(
+ $self,
+ $self->_default_immutable_transformer_options,
+ @_
+ );
}
sub make_mutable {
use strict;
use warnings;
-use Test::More tests => 244;
+use Test::More tests => 248;
use Test::Exception;
use Class::MOP;
is_mutable is_immutable make_mutable make_immutable
immutable_transformer _set_immutable_transformer
+ _make_immutable_transformer
+ _default_immutable_transformer_options
DESTROY
);