From: Yuval Kogman Date: Mon, 23 Jun 2008 10:14:44 +0000 (+0000) Subject: error_class and error_builder are readonly in immutable classes X-Git-Tag: 0.58~54^2~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=87567f12f646b8a3ab2f40395e8c3b940f3355b9;p=gitmo%2FMoose.git error_class and error_builder are readonly in immutable classes --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index c933538..c4f057d 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -379,36 +379,41 @@ use Moose::Meta::Method::Destructor; sub create_immutable_transformer { my $self = shift; my $class = Class::MOP::Immutable->new($self, { - read_only => [qw/superclasses/], - cannot_call => [qw/ - add_method - alias_method - remove_method - add_attribute - remove_attribute - remove_package_symbol - add_role - /], - memoize => { - class_precedence_list => 'ARRAY', - compute_all_applicable_attributes => 'ARRAY', - get_meta_instance => 'SCALAR', - get_method_map => 'SCALAR', - # maybe .... - calculate_all_roles => 'ARRAY', - }, - # NOTE: - # this is ugly, but so are typeglobs, - # so whattayahgonnadoboutit - # - SL - wrapped => { - add_package_symbol => sub { - my $original = shift; - $self->throw_error("Cannot add package symbols to an immutable metaclass") - unless (caller(2))[3] eq 'Class::MOP::Package::get_package_symbol'; - goto $original->body; - }, - }, + read_only => [qw/ + superclasses + roles + error_class + error_builder + /], + cannot_call => [qw/ + add_method + alias_method + remove_method + add_attribute + remove_attribute + remove_package_symbol + add_role + /], + memoize => { + class_precedence_list => 'ARRAY', + compute_all_applicable_attributes => 'ARRAY', + get_meta_instance => 'SCALAR', + get_method_map => 'SCALAR', + # maybe .... + calculate_all_roles => 'ARRAY', + }, + # NOTE: + # this is ugly, but so are typeglobs, + # so whattayahgonnadoboutit + # - SL + wrapped => { + add_package_symbol => sub { + my $original = shift; + $self->throw_error("Cannot add package symbols to an immutable metaclass") + unless (caller(2))[3] eq 'Class::MOP::Package::get_package_symbol'; + goto $original->body; + }, + }, }); return $class; }