[Moose-commits] r7192 - in
MooseX-Emulate-Class-Accessor-Fast/trunk: .
lib/MooseX/Emulate/Class/Accessor
groditi at code2.0beta.co.uk
groditi at code2.0beta.co.uk
Mon Dec 29 17:57:58 GMT 2008
Author: groditi
Date: 2008-12-29 09:57:58 -0800 (Mon, 29 Dec 2008)
New Revision: 7192
Modified:
MooseX-Emulate-Class-Accessor-Fast/trunk/Changes
MooseX-Emulate-Class-Accessor-Fast/trunk/lib/MooseX/Emulate/Class/Accessor/Fast.pm
Log:
immutable error
Modified: MooseX-Emulate-Class-Accessor-Fast/trunk/Changes
===================================================================
--- MooseX-Emulate-Class-Accessor-Fast/trunk/Changes 2008-12-29 17:30:58 UTC (rev 7191)
+++ MooseX-Emulate-Class-Accessor-Fast/trunk/Changes 2008-12-29 17:57:58 UTC (rev 7192)
@@ -1,3 +1,5 @@
+0.00800
+ - Better errors when trying to modify an immutable class
0.00700 Dec 29, 2008
- Creating a new accessor with the same name as an old one would result in
a new attribute with no reader/writer/accessor. Reported by t0m
Modified: MooseX-Emulate-Class-Accessor-Fast/trunk/lib/MooseX/Emulate/Class/Accessor/Fast.pm
===================================================================
--- MooseX-Emulate-Class-Accessor-Fast/trunk/lib/MooseX/Emulate/Class/Accessor/Fast.pm 2008-12-29 17:30:58 UTC (rev 7191)
+++ MooseX-Emulate-Class-Accessor-Fast/trunk/lib/MooseX/Emulate/Class/Accessor/Fast.pm 2008-12-29 17:57:58 UTC (rev 7192)
@@ -102,6 +102,11 @@
sub mk_accessors{
my $self = shift;
my $meta = $locate_metaclass->($self);
+ my $class = $meta->name;
+ confess("You are trying to modify ${class}, which has been made immutable, this is ".
+ "not supported. Try subclassing ${class}, rather than monkeypatching it")
+ if $meta->is_immutable;
+
for my $attr_name (@_){
$meta->remove_attribute($attr_name)
if $meta->find_attribute_by_name($attr_name);
@@ -135,6 +140,10 @@
sub mk_ro_accessors{
my $self = shift;
my $meta = $locate_metaclass->($self);
+ my $class = $meta->name;
+ confess("You are trying to modify ${class}, which has been made immutable, this is ".
+ "not supported. Try subclassing ${class}, rather than monkeypatching it")
+ if $meta->is_immutable;
for my $attr_name (@_){
$meta->remove_attribute($attr_name)
if $meta->find_attribute_by_name($attr_name);
@@ -158,6 +167,10 @@
sub mk_wo_accessors{
my $self = shift;
my $meta = $locate_metaclass->($self);
+ my $class = $meta->name;
+ confess("You are trying to modify ${class}, which has been made immutable, this is ".
+ "not supported. Try subclassing ${class}, rather than monkeypatching it")
+ if $meta->is_immutable;
for my $attr_name (@_){
$meta->remove_attribute($attr_name)
if $meta->find_attribute_by_name($attr_name);
More information about the Moose-commits
mailing list