Author: timbo
Date: Fri Feb 2 04:49:12 2007
New Revision: 8790
Added:
dbi/trunk/lib/DBI/Util/
dbi/trunk/lib/DBI/Util/_accessor.pm
Modified:
dbi/trunk/MANIFEST
dbi/trunk/lib/DBI/Gofer/Request.pm
dbi/trunk/lib/DBI/Gofer/Response.pm
dbi/trunk/lib/DBI/Gofer/Transport/Base.pm
Log:
Add DBI::Util::_accessor and use instead of Class::Accessor::Fast
Modified: dbi/trunk/MANIFEST
==============================================================================
--- dbi/trunk/MANIFEST (original)
+++ dbi/trunk/MANIFEST Fri Feb 2 04:49:12 2007
@@ -53,6 +53,7 @@
lib/DBI/ProxyServer.pm The proxy drivers server
lib/DBI/PurePerl.pm A DBI.xs emulation in Perl
lib/DBI/SQL/Nano.pm A 'smaller than micro' SQL parser
+lib/DBI/Util/_accessor.pm A cut-down version of Class::Accessor::Fast
lib/DBI/W32ODBC.pm An experimental DBI emulation layer for
Win32::ODBC
lib/Win32/DBIODBC.pm An experimental Win32::ODBC emulation layer for
DBI
t/01basics.t
Modified: dbi/trunk/lib/DBI/Gofer/Request.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Request.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Request.pm Fri Feb 2 04:49:12 2007
@@ -7,7 +7,7 @@
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
-use base qw(Class::Accessor::Fast);
+use base qw(DBI::Util::_accessor);
our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
Modified: dbi/trunk/lib/DBI/Gofer/Response.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Response.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Response.pm Fri Feb 2 04:49:12 2007
@@ -7,7 +7,7 @@
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
-use base qw(Class::Accessor::Fast);
+use base qw(DBI::Util::_accessor);
our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
Modified: dbi/trunk/lib/DBI/Gofer/Transport/Base.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Transport/Base.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Transport/Base.pm Fri Feb 2 04:49:12 2007
@@ -12,7 +12,7 @@
use Storable qw(freeze thaw);
-use base qw(Class::Accessor::Fast);
+use base qw(DBI::Util::_accessor);
our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
Added: dbi/trunk/lib/DBI/Util/_accessor.pm
==============================================================================
--- (empty file)
+++ dbi/trunk/lib/DBI/Util/_accessor.pm Fri Feb 2 04:49:12 2007
@@ -0,0 +1,44 @@
+package DBI::Util::_accessor;
+use strict;
+our $VERSION = sprintf("0.%06d", q$Revision: 8696 $ =~ /(\d+)/);
+
+# heavily cut-down (but compatible) version of Class::Accessor::Fast to avoid
the dependency
+
+sub new {
+ my($proto, $fields) = @_;
+ my($class) = ref $proto || $proto;
+ $fields = {} unless defined $fields;
+ # make a copy of $fields.
+ bless {%$fields}, $class;
+}
+
+sub mk_accessors {
+ my($self, @fields) = @_;
+ $self->_mk_accessors('make_accessor', @fields);
+}
+
+sub _mk_accessors {
+ my($self, $maker, @fields) = @_;
+ my $class = ref $self || $self;
+
+ # So we don't have to do lots of lookups inside the loop.
+ $maker = $self->can($maker) unless ref $maker;
+
+ no strict 'refs';
+ foreach my $field (@fields) {
+ my $accessor = $self->$maker($field);
+ *{$class."\:\:$field"} = $accessor
+ unless defined &{$class."\:\:$field"};
+ }
+}
+
+sub make_accessor {
+ my($class, $field) = @_;
+ return sub {
+ my $self = shift;
+ return $self->{$field} unless @_;
+ $self->{$field} = (@_ == 1 ? $_[0] : [EMAIL PROTECTED]);
+ };
+}
+
+1;