use Carp 'confess';
use Scalar::Util 'blessed', 'weaken';
-our $VERSION = '0.92';
+our $VERSION = '1.00';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
# the original class of the metaclass instance
sub _get_mutable_metaclass_name { $_[0]{__immutable}{original_class} }
-sub immutable_options { %{ $_[0]{__immutable}{options} } }
-
sub is_mutable { 0 }
sub is_immutable { 1 }
}
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;
$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 {