r2818 - in /packages/libclass-data-accessor-perl/trunk: Changes
MANIFEST.SKIP META.yml README debian/changelog debian/control
lib/Class/Data/Accessor.pm t/Accessor.t
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Tue May 30 14:41:42 UTC 2006
Author: eloy
Date: Tue May 30 14:41:41 2006
New Revision: 2818
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=2818
Log:
eloy: new upstream version
Modified:
packages/libclass-data-accessor-perl/trunk/Changes
packages/libclass-data-accessor-perl/trunk/MANIFEST.SKIP
packages/libclass-data-accessor-perl/trunk/META.yml
packages/libclass-data-accessor-perl/trunk/README
packages/libclass-data-accessor-perl/trunk/debian/changelog
packages/libclass-data-accessor-perl/trunk/debian/control
packages/libclass-data-accessor-perl/trunk/lib/Class/Data/Accessor.pm
packages/libclass-data-accessor-perl/trunk/t/Accessor.t
Modified: packages/libclass-data-accessor-perl/trunk/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-data-accessor-perl/trunk/Changes?rev=2818&op=diff
==============================================================================
--- packages/libclass-data-accessor-perl/trunk/Changes (original)
+++ packages/libclass-data-accessor-perl/trunk/Changes Tue May 30 14:41:41 2006
@@ -1,4 +1,9 @@
Revision history for Class::Data::Accessor.
+
+0.03 2006-06-23 19:50:23
+ - Added warning when attempting to make DESTROY accessor
+ - Added mk_classaccessors class method
+ - Doc patch (Aran Deltac)
0.02
- Doc fixes
Modified: packages/libclass-data-accessor-perl/trunk/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-data-accessor-perl/trunk/MANIFEST.SKIP?rev=2818&op=diff
==============================================================================
--- packages/libclass-data-accessor-perl/trunk/MANIFEST.SKIP (original)
+++ packages/libclass-data-accessor-perl/trunk/MANIFEST.SKIP Tue May 30 14:41:41 2006
@@ -27,6 +27,7 @@
\.bak$
\.swp$
\.tdy$
+\.tmp$
\#$
\b\.#
Modified: packages/libclass-data-accessor-perl/trunk/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-data-accessor-perl/trunk/META.yml?rev=2818&op=diff
==============================================================================
--- packages/libclass-data-accessor-perl/trunk/META.yml (original)
+++ packages/libclass-data-accessor-perl/trunk/META.yml Tue May 30 14:41:41 2006
@@ -1,6 +1,6 @@
---
name: Class-Data-Accessor
-version: 0.02
+version: 0.03
author: ~
abstract: 'Inheritable, overridable class and instance data accessor creation'
license: perl
@@ -9,5 +9,5 @@
provides:
Class::Data::Accessor:
file: lib/Class/Data/Accessor.pm
- version: 0.02
+ version: 0.03
generated_by: Module::Build version 0.26
Modified: packages/libclass-data-accessor-perl/trunk/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-data-accessor-perl/trunk/README?rev=2818&op=diff
==============================================================================
--- packages/libclass-data-accessor-perl/trunk/README (original)
+++ packages/libclass-data-accessor-perl/trunk/README Tue May 30 14:41:41 2006
@@ -91,7 +91,10 @@
If you don't want this behaviour use Class::Data::Inheritable instead.
-Methods
+ "mk_classaccessor" will die if used as an object method instead of as a
+ class method.
+
+METHODS
mk_classaccessor
Class->mk_classaccessor($data_accessor_name);
Class->mk_classaccessor($data_accessor_name => $value);
@@ -113,6 +116,16 @@
$self->_Suitcase_accessor(@_);
}
+
+ Overriding accessors does not work in the same class as you declare the
+ accessor in. It only works in subclasses due to the fact that
+ subroutines are loaded at compile time and accessors are loaded at
+ runtime, thus overriding any subroutines with the same name in the same
+ class.
+
+ mk_classaccessors(@accessornames)
+ Takes a list of names and generates an accessor for each name in the
+ list using "mk_classaccessor".
AUTHORS
Based on the creative stylings of Damian Conway, Michael G Schwern, Tony
Modified: packages/libclass-data-accessor-perl/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-data-accessor-perl/trunk/debian/changelog?rev=2818&op=diff
==============================================================================
--- packages/libclass-data-accessor-perl/trunk/debian/changelog (original)
+++ packages/libclass-data-accessor-perl/trunk/debian/changelog Tue May 30 14:41:41 2006
@@ -1,3 +1,11 @@
+libclass-data-accessor-perl (0.03-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/control:
+ - Standards-Version: increased to 3.7.2 without any changes
+
+ -- Krzysztof Krzyzaniak (eloy) <eloy at debian.org> Tue, 30 May 2006 16:39:47 +0200
+
libclass-data-accessor-perl (0.02-2) unstable; urgency=low
* Long description fixed (closes: #346290)
Modified: packages/libclass-data-accessor-perl/trunk/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-data-accessor-perl/trunk/debian/control?rev=2818&op=diff
==============================================================================
--- packages/libclass-data-accessor-perl/trunk/debian/control (original)
+++ packages/libclass-data-accessor-perl/trunk/debian/control Tue May 30 14:41:41 2006
@@ -5,7 +5,7 @@
Build-Depends: debhelper (>= 4.0.2),
Build-Depends-Indep: perl (>= 5.8.0-7), libmodule-build-perl, libtest-pod-perl, libtest-pod-coverage-perl
Uploaders: Krzysztof Krzyzaniak (eloy) <eloy at debian.org>
-Standards-Version: 3.6.2
+Standards-Version: 3.7.2
Package: libclass-data-accessor-perl
Architecture: all
Modified: packages/libclass-data-accessor-perl/trunk/lib/Class/Data/Accessor.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-data-accessor-perl/trunk/lib/Class/Data/Accessor.pm?rev=2818&op=diff
==============================================================================
--- packages/libclass-data-accessor-perl/trunk/lib/Class/Data/Accessor.pm (original)
+++ packages/libclass-data-accessor-perl/trunk/lib/Class/Data/Accessor.pm Tue May 30 14:41:41 2006
@@ -1,14 +1,18 @@
package Class::Data::Accessor;
use strict qw(vars subs);
+use Carp;
use vars qw($VERSION);
-$VERSION = '0.02';
+$VERSION = '0.03';
sub mk_classaccessor {
my ($declaredclass, $attribute, $data) = @_;
if( ref $declaredclass ) {
- require Carp;
- Carp::croak("mk_classaccessor() is a class method, not an object method");
+ croak("mk_classaccessor() is a class method, not an object method");
+ }
+
+ if( $attribute eq 'DESTROY' ) {
+ carp("Having a data accessor named DESTROY in '$declaredclass' is unwise.");
}
my $accessor = sub {
@@ -32,6 +36,14 @@
*{$declaredclass.'::'.$alias} = $accessor;
}
+sub mk_classaccessors {
+ my ($declaredclass, @attributes) = @_;
+
+ foreach my $attribute (@attributes) {
+ $declaredclass->mk_classaccessor($attribute);
+ }
+};
+
__END__
=head1 NAME
@@ -130,7 +142,10 @@
If you don't want this behaviour use L<Class::Data::Inheritable> instead.
-=head1 Methods
+C<mk_classaccessor> will die if used as an object method instead of as a
+class method.
+
+=head1 METHODS
=head2 mk_classaccessor
@@ -155,6 +170,17 @@
$self->_Suitcase_accessor(@_);
}
+Overriding accessors does not work in the same class as you declare
+the accessor in. It only works in subclasses due to the fact that
+subroutines are loaded at compile time and accessors are loaded at
+runtime, thus overriding any subroutines with the same name in the
+same class.
+
+=head2 mk_classaccessors(@accessornames)
+
+Takes a list of names and generates an accessor for each name in the list using
+C<mk_classaccessor>.
+
=head1 AUTHORS
Based on the creative stylings of Damian Conway, Michael G Schwern,
Modified: packages/libclass-data-accessor-perl/trunk/t/Accessor.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-data-accessor-perl/trunk/t/Accessor.t?rev=2818&op=diff
==============================================================================
--- packages/libclass-data-accessor-perl/trunk/t/Accessor.t (original)
+++ packages/libclass-data-accessor-perl/trunk/t/Accessor.t Tue May 30 14:41:41 2006
@@ -1,5 +1,5 @@
use strict;
-use Test::More tests => 17;
+use Test::More tests => 19;
package Ray;
use base qw(Class::Data::Accessor);
@@ -49,3 +49,28 @@
"And they can set their own copy";
is +Gun->DataFile, "/tmp/stuff", "But it doesn't touch the value on the class";
+
+
+{
+ my $warned = 0;
+
+ local $SIG{__WARN__} = sub {
+ if (shift =~ /DESTROY/i) {
+ $warned++;
+ };
+ };
+
+ Ray->mk_classaccessor('DESTROY');
+
+ ok($warned, 'Warn when creating DESTROY');
+
+ # restore non-accessorized DESTROY
+ no warnings;
+ *Ray::DESTROY = sub {};
+};
+
+eval {
+ $obj->mk_classaccessor('foo');
+};
+like($@, qr{not an object method}, 'Die when used as an object method');
+
More information about the Pkg-perl-cvs-commits
mailing list