Showing 4 changed files with 75 additions and 44 deletions
-10
.cvsignore
... ...
@@ -1,10 +0,0 @@
1
-blib*
2
-Makefile
3
-Makefile.old
4
-Build
5
-_build*
6
-pm_to_blib*
7
-*.tar.gz
8
-.lwpcookies
9
-DBI-Custom-*
10
-cover_db
+2 -1
Build.PL
... ...
@@ -11,7 +11,8 @@ my $builder = Module::Build->new(
11 11
         'Test::More' => 0,
12 12
     },
13 13
     requires => {
14
-        'Object::Simple' => 0.0602,
14
+        'Object::Simple' => 2.0701,
15
+        'DBI'            => 1.605,
15 16
     },
16 17
     add_to_cleanup      => [ 'DBI-Custom-*' ],
17 18
     create_makefile_pl => 'traditional',
+35 -33
lib/DBI/Custom.pm
... ...
@@ -9,8 +9,9 @@ use DBI::Custom::SQL::Template;
9 9
 use DBI::Custom::Result;
10 10
 
11 11
 ### Class-Object Accessors
12
-sub connect_info : ClassObjectAttr { type => 'hash',  auto_build => sub {
13
-    shift->Object::Simple::initialize_class_object_attr(
12
+sub connect_info : ClassObjectAttr {
13
+    type => 'hash',
14
+    initialize => {
14 15
         clone => sub {
15 16
             my $value = shift;
16 17
             my $new_value = \%{$value || {}};
... ...
@@ -18,43 +19,48 @@ sub connect_info : ClassObjectAttr { type => 'hash',  auto_build => sub {
18 19
             return $new_value;
19 20
         },
20 21
         default => sub { {} },
21
-    )
22
-}}
23
-
24
-sub bind_filter  : ClassObjectAttr { auto_build => sub {
25
-    shift->Object::Simple::initialize_class_object_attr(clone => 'scalar')
26
-}}
27
-sub fetch_filter : ClassObjectAttr { auto_build => sub {
28
-    shift->Object::Simple::initialize_class_object_attr(clone => 'scalar')
29
-}}
30
-
31
-sub filters : ClassObjectAttr { type => 'hash', deref => 1, auto_build => sub {
32
-    shift->Object::Simple::initialize_class_object_attr(
22
+    }
23
+}
24
+
25
+sub bind_filter  : ClassObjectAttr {
26
+    initialize => {clone => 'scalar'}
27
+}
28
+
29
+sub fetch_filter : ClassObjectAttr {
30
+    initialize => {clone => 'scalar'}
31
+}
32
+
33
+sub filters : ClassObjectAttr {
34
+    type => 'hash',
35
+    deref => 1,
36
+    initialize => {
33 37
         clone   => 'hash',
34 38
         default => sub { {} }
35
-    )
36
-}}
39
+    }
40
+}
37 41
 
38
-sub result_class : ClassObjectAttr { auto_build => sub {
39
-    shift->Object::Simple::initialize_class_object_attr(
42
+sub result_class : ClassObjectAttr {
43
+    initialize => {
40 44
         clone   => 'scalar',
41 45
         default => 'DBI::Custom::Result'
42
-    )
43
-}}
46
+    }
47
+}
44 48
 
45
-sub sql_template : ClassObjectAttr { auto_build => sub {
46
-    shift->Object::Simple::initialize_class_object_attr(
49
+sub sql_template : ClassObjectAttr {
50
+    initialize => {
47 51
         clone   => sub {my $value = shift; $value ? $value->clone : undef},
48
-        default => sub { DBI::Custom::SQL::Template->new }
49
-    )
50
-}}
52
+        default => sub {DBI::Custom::SQL::Template->new}
53
+    }
54
+}
51 55
 
52
-sub valid_connect_info : ClassObjectAttr { type => 'hash', deref => 1, auto_build => sub {
53
-    shift->Object::Simple::initialize_class_object_attr(
56
+sub valid_connect_info : ClassObjectAttr {
57
+    type => 'hash',
58
+    deref => 1,
59
+    initialize => {
54 60
         clone => 'hash',
55 61
         default => sub { return {map {$_ => 1} qw/data_source user password options/} },
56
-    )
57
-}}
62
+    }
63
+}
58 64
 
59 65
 ### Object Accessor
60 66
 sub dbh          : Attr {}
... ...
@@ -250,8 +256,6 @@ Version 0.0101
250 256
 
251 257
 =head2 bind_filter
252 258
 
253
-=head2 clone
254
-
255 259
 =head2 connect
256 260
 
257 261
 =head2 connect_info
... ...
@@ -262,8 +266,6 @@ Version 0.0101
262 266
 
263 267
 =head2 filters
264 268
 
265
-=head2 prototype
266
-
267 269
 =head2 new
268 270
 
269 271
 =head2 query
+38
t/101-mysql_private.t
... ...
@@ -0,0 +1,38 @@
1
+use Test::More;
2
+use strict;
3
+use warnings;
4
+
5
+# user password database
6
+our ($U, $P, $D) = connect_info();
7
+
8
+plan skip_all => 'private MySQL test' unless $U;
9
+
10
+plan 'no_plan';
11
+
12
+use DBI::Custom;
13
+use Scalar::Util 'blessed';
14
+{
15
+    my $dbi = DBI::Custom->new(
16
+        connect_info => {
17
+            user => $U,
18
+            password => $P,
19
+            data_source => "dbi:mysql:$D"
20
+        }
21
+    );
22
+    $dbi->connect;
23
+    
24
+    ok(blessed $dbi->dbh);
25
+    can_ok($dbi->dbh, qw/prepare/);
26
+}
27
+
28
+sub connect_info {
29
+    my $file = 'password.tmp';
30
+    open my $fh, '<', $file
31
+      or return;
32
+    
33
+    my ($user, $password, $database) = split(/\s/, (<$fh>)[0]);
34
+    
35
+    close $fh;
36
+    
37
+    return ($user, $password, $database);
38
+}