dependency on Class::Inspector
- Simplify superclass traversal done by the 'inherited' group type
- Fix incorrect quoting of unusual hash keys (fieldnames)
+ - Improve text of ro/wo violation exceptions
0.10006 2011-12-30 03:52 (UTC)
- Silence warnings resulting from incomplete can() overrides
pp_code => sub {
# my ($group, $fieldname) = @_;
my $quoted_fieldname = $perlstring->($_[1]);
- sprintf <<'EOS', $quoted_fieldname, $_[0], $quoted_fieldname;
+ sprintf <<'EOS', $_[0], $quoted_fieldname;
@_ > 1
? do {
- my $caller = caller;
+ my ($meth) = (caller(0))[3] =~ /([^\:]+)$/;
my $class = length( ref($_[0]) ) ? ref($_[0]) : $_[0];
- Carp::croak(sprintf
- "'%%s' cannot alter the value of '%%s' (read-only attribute of class '%%s')",
- $caller, %s, $class
+ Carp::croak(
+ "'$meth' cannot alter its value (read-only attribute of class $class)"
);
}
: shift->get_%s(%s)
pp_code => sub {
# my ($group, $fieldname) = @_;
my $quoted_fieldname = $perlstring->($_[1]);
- sprintf <<'EOS', $_[0], ($quoted_fieldname) x 2;
+ sprintf <<'EOS', $_[0], $quoted_fieldname;
@_ > 1
? shift->set_%s(%s, @_)
: do {
- my $caller = caller;
+ my ($meth) = (caller(0))[3] =~ /([^\:]+)$/;
my $class = length( ref($_[0]) ) ? ref($_[0]) : $_[0];
- Carp::croak(sprintf
- "'%%s' cannot access the value of '%%s' (write-only attribute of class '%%s')",
- $caller, %s, $class
+ Carp::croak(
+ "'$meth' cannot access its value (write-only attribute of class $class)"
);
}
EOS
my $ro_regex = $test_accessors->{$name}{is_xs}
? qr/Usage\:.+$name.*\(self\)/
- : qr/cannot alter the value of '\Q$field\E'/
+ : qr/$name(:?_accessor)?\Q' cannot alter its value (read-only attribute of class AccessorGroupsRO)/
;
{
my $wo_regex = $test_accessors->{$name}{is_xs}
? qr/Usage\:.+$name.*\(self, newvalue\)/
- : qr/cannot access the value of '\Q$field\E'/
+ : qr/$name(:?_accessor)?\Q' cannot access its value (write-only attribute of class AccessorGroupsWO)/
;
# die on get via name/alias