X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FClass%2FImmutable%2FTrait.pm;h=136b82984d3897736944d741ff5e973397166cd4;hb=936e37acb41fce39498ffe721741bedf01ac818e;hp=724ca5916a39eb015577499c17a0db2cfe13bca4;hpb=07a0558391d3232b2fccdbb57d64230087363555;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Class/Immutable/Trait.pm b/lib/Class/MOP/Class/Immutable/Trait.pm index 724ca59..136b829 100644 --- a/lib/Class/MOP/Class/Immutable/Trait.pm +++ b/lib/Class/MOP/Class/Immutable/Trait.pm @@ -8,7 +8,7 @@ use MRO::Compat; use Carp 'confess'; use Scalar::Util 'blessed', 'weaken'; -our $VERSION = '0.92'; +our $VERSION = '0.96'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -28,15 +28,14 @@ sub superclasses { } sub _immutable_cannot_call { - Carp::confess "This method cannot be called on an immutable instance"; + my $name = shift; + Carp::confess "The '$name' method cannot be called on an immutable instance"; } -sub add_method { _immutable_cannot_call() } -sub alias_method { _immutable_cannot_call() } -sub remove_method { _immutable_cannot_call() } -sub add_attribute { _immutable_cannot_call() } -sub remove_attribute { _immutable_cannot_call() } -sub remove_package_symbol { _immutable_cannot_call() } +for my $name (qw/add_method alias_method remove_method add_attribute remove_attribute remove_package_symbol/) { + no strict 'refs'; + *{__PACKAGE__."::$name"} = sub { _immutable_cannot_call($name) }; +} sub class_precedence_list { my $orig = shift; @@ -75,10 +74,10 @@ sub get_meta_instance { $self->{__immutable}{get_meta_instance} ||= $self->$orig; } -sub get_method_map { +sub _get_method_map { my $orig = shift; my $self = shift; - $self->{__immutable}{get_method_map} ||= $self->$orig; + $self->{__immutable}{_get_method_map} ||= $self->$orig; } sub add_package_symbol {