Showing 11 changed files with 71 additions and 95 deletions
+1 -1
Build.PL
... ...
@@ -11,7 +11,7 @@ my $builder = Module::Build->new(
11 11
         'Test::More' => 0,
12 12
     },
13 13
     requires => {
14
-        'Object::Simple' => 2.0702,
14
+        'Object::Simple' => 2.1301,
15 15
         'DBI'            => 1.605,
16 16
         'DBD::SQLite'    => 1.25,
17 17
         'Time::Piece'    => 1.15
+4
Changes
... ...
@@ -1,3 +1,7 @@
1
+0.0903
2
+  catch up with Object::Simple update
3
+0.0902
4
+  cleanup
1 5
 0.0901
2 6
   DBIx::Basic filter 'encode_utf8' utf8::upgrade process is deleted
3 7
 0.0801
+26 -33
lib/DBIx/Custom.pm 1000755 → 1000644
... ...
@@ -6,59 +6,48 @@ use warnings;
6 6
 
7 7
 use 5.008001;
8 8
 
9
-
10
-our $VERSION = '0.0901';
11
-
12 9
 use Carp 'croak';
13 10
 use DBI;
14 11
 use DBIx::Custom::Result;
15 12
 use DBIx::Custom::SQL::Template;
16 13
 
17
-my $p = __PACKAGE__;
18
-
19
-$p->attr('dbh');
20
-
21
-$p->class_attr(_query_caches     => (type => 'hash',  default => sub { {} }))
22
-  ->class_attr(_query_cache_keys => (type => 'array', default => sub { [] }))
23
-  ->class_attr(query_cache_max   => 50);
24
-
25
-$p->hybrid_attr([qw/user password data_source
26
-                   database host port 
27
-                   bind_filter fetch_filter/] => (clone => 'scalar'));
14
+__PACKAGE__->attr('dbh');
28 15
 
29
-$p->hybrid_attr([qw/no_bind_filters no_fetch_filters/]
30
-            => (type => 'array', default => sub { [] }, clone => 'array'));
16
+__PACKAGE__->class_attr(_query_caches     => sub { {} });
17
+__PACKAGE__->class_attr(_query_cache_keys => sub { [] });
18
+__PACKAGE__->class_attr('query_cache_max', default => 50, clone => 'scalar');
31 19
 
32
-$p->hybrid_attr(options => (type  => 'hash', default => sub { {} },
33
-                            clone => 'hash'));
20
+__PACKAGE__->dual_attr([qw/user password data_source/], clone => 'scalar');
21
+__PACKAGE__->dual_attr([qw/database host port/],        clone => 'scalar');
22
+__PACKAGE__->dual_attr([qw/bind_filter fetch_filter/],  clone => 'scalar');
34 23
 
35
-$p->hybrid_attr([qw/filters formats/]
36
-            => (type => 'hash', default => sub { {} },
37
-                deref => 1,     clone   => 'hash'));
24
+__PACKAGE__->dual_attr([qw/no_bind_filters no_fetch_filters/],
25
+                       default => sub { [] }, clone => 'array');
38 26
 
39
-$p->hybrid_attr(result_class => (default => 'DBIx::Custom::Result',
40
-                                 clone   => 'scalar'));
27
+__PACKAGE__->dual_attr([qw/options filters formats/],
28
+                       default => sub { {} }, clone => 'hash');
41 29
 
42
-$p->hybrid_attr(sql_tmpl => (default => sub {DBIx::Custom::SQL::Template->new},
43
-                             clone => sub {$_[0] ? $_[0]->clone : undef}));
30
+__PACKAGE__->dual_attr('result_class', default => 'DBIx::Custom::Result',
31
+                                       clone   => 'scalar');
44 32
 
45
-### Methods
33
+__PACKAGE__->dual_attr('sql_tmpl', default => sub {DBIx::Custom::SQL::Template->new},
34
+                                   clone   => sub {$_[0] ? $_[0]->clone : undef});
46 35
 
47 36
 sub add_filter {
48 37
     my $invocant = shift;
49 38
     
50
-    my %old_filters = $invocant->filters;
51
-    my %new_filters = ref $_[0] eq 'HASH' ? %{$_[0]} : @_;
52
-    $invocant->filters(%old_filters, %new_filters);
39
+    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
40
+    $invocant->filters({%{$invocant->filters}, %$filters});
41
+    
53 42
     return $invocant;
54 43
 }
55 44
 
56 45
 sub add_format{
57 46
     my $invocant = shift;
58 47
     
59
-    my %old_formats = $invocant->formats;
60
-    my %new_formats = ref $_[0] eq 'HASH' ? %{$_[0]} : @_;
61
-    $invocant->formats(%old_formats, %new_formats);
48
+    my $formats = ref $_[0] eq 'HASH' ? $_[0] : {@_};
49
+    $invocant->formats({%{$invocant->formats}, %$formats});
50
+
62 51
     return $invocant;
63 52
 }
64 53
 
... ...
@@ -737,7 +726,11 @@ DBIx::Custom - Customizable DBI
737 726
 
738 727
 =head1 VERSION
739 728
 
740
-Version 0.0801
729
+Version 0.0903
730
+
731
+=cut
732
+
733
+our $VERSION = '0.0903';
741 734
 
742 735
 =head1 SYNOPSYS
743 736
     
+2 -4
lib/DBIx/Custom/Basic.pm
... ...
@@ -5,14 +5,12 @@ use warnings;
5 5
 use strict;
6 6
 use Encode qw/decode encode/;
7 7
 
8
-my $class = __PACKAGE__;
9
-
10
-$class->add_filter(
8
+__PACKAGE__->add_filter(
11 9
     encode_utf8 => sub { encode('UTF-8', shift) },
12 10
     decode_utf8 => sub { decode('UTF-8', shift) }
13 11
 );
14 12
 
15
-$class->add_format(
13
+__PACKAGE__->add_format(
16 14
     'SQL99_date'        => '%Y-%m-%d',
17 15
     'SQL99_datetime'    => '%Y-%m-%d %H:%M:%S',
18 16
     'SQL99_time'        => '%H:%M:%S',
+4 -6
lib/DBIx/Custom/MySQL.pm 1000755 → 1000644
... ...
@@ -5,12 +5,10 @@ use warnings;
5 5
 use strict;
6 6
 use Carp 'croak';
7 7
 
8
-my $p = __PACKAGE__;
9
-
10
-$p->add_format(
11
-    datetime => $p->formats->{SQL99_datetime},
12
-    date     => $p->formats->{SQL99_date},
13
-    time     => $p->formats->{SQL99_time},
8
+__PACKAGE__->add_format(
9
+    datetime => __PACKAGE__->formats->{SQL99_datetime},
10
+    date     => __PACKAGE__->formats->{SQL99_date},
11
+    time     => __PACKAGE__->formats->{SQL99_time},
14 12
 );
15 13
 
16 14
 
+5 -7
lib/DBIx/Custom/Query.pm 1000755 → 1000644
... ...
@@ -4,18 +4,16 @@ use base 'Object::Simple::Base';
4 4
 use strict;
5 5
 use warnings;
6 6
 
7
-my $p = __PACKAGE__;
7
+__PACKAGE__->attr([qw/sql key_infos bind_filter fetch_filter sth/]);
8
+__PACKAGE__->attr(_no_bind_filters_map => sub { {} });
9
+__PACKAGE__->attr(no_fetch_filters => sub { [] });
8 10
 
9
-$p->attr([qw/sql key_infos bind_filter fetch_filter sth/])
10
-  ->attr(_no_bind_filters_map => sub { {} })
11
-  ->attr(no_fetch_filters => (type => 'array', default => sub { [] }));
12
-
13
-$p->attr(no_bind_filters => (type => 'array', trigger => sub {
11
+__PACKAGE__->attr('no_bind_filters', trigger => sub {
14 12
     my $self = shift;
15 13
     my $no_bind_filters = $self->no_bind_filters || [];
16 14
     my %no_bind_filters_map = map {$_ => 1} @{$no_bind_filters};
17 15
     $self->_no_bind_filters_map(\%no_bind_filters_map);
18
-}));
16
+});
19 17
 
20 18
 sub new {
21 19
     my $self = shift->SUPER::new(@_);
+4 -6
lib/DBIx/Custom/Result.pm 1000755 → 1000644
... ...
@@ -7,17 +7,15 @@ use Carp 'croak';
7 7
 
8 8
 use Object::Simple::Util;
9 9
 
10
-my $p = __PACKAGE__;
10
+__PACKAGE__->attr([qw/_dbi sth fetch_filter/]);
11
+__PACKAGE__->attr(_no_fetch_filters_map => sub { {} });
11 12
 
12
-$p->attr([qw/_dbi sth fetch_filter/])
13
-  ->attr(_no_fetch_filters_map => sub { {} });
14
-
15
-$p->attr(no_fetch_filters => (type => 'array', trigger => sub {
13
+__PACKAGE__->attr('no_fetch_filters', trigger => sub {
16 14
     my $self = shift;
17 15
     my $no_fetch_filters = $self->no_fetch_filters || [];
18 16
     my %no_fetch_filters_map = map {$_ => 1} @{$no_fetch_filters};
19 17
     $self->_no_fetch_filters_map(\%no_fetch_filters_map);
20
-}));
18
+});
21 19
 
22 20
 sub new {
23 21
     my $self = shift->SUPER::new(@_);
+8 -10
lib/DBIx/Custom/SQL/Template.pm 1000755 → 1000644
... ...
@@ -7,17 +7,15 @@ use Carp 'croak';
7 7
 
8 8
 use DBIx::Custom::Query;
9 9
 
10
-my $p = __PACKAGE__;
10
+__PACKAGE__->dual_attr('tag_processors', default => sub { {} },
11
+                                         clone   => 'hash');
11 12
 
12
-$p->hybrid_attr(tag_processors => (type  => 'hash', default => sub { {} },
13
-                                   deref => 1,      clone   => 'hash'));
13
+__PACKAGE__->dual_attr('tag_start', default => '{', clone => 'scalar');
14
+__PACKAGE__->dual_attr('tag_end',   default => '}', clone => 'scalar');
14 15
 
15
-$p->hybrid_attr(tag_start => (default => '{', clone => 'scalar'))
16
-  ->hybrid_attr(tag_end   => (default => '}', clone => 'scalar'));
16
+__PACKAGE__->dual_attr('tag_syntax', clone => 'scalar');
17 17
 
18
-$p->hybrid_attr(tag_syntax => (clone => 'scalar'));
19
-
20
-$p->add_tag_processor(
18
+__PACKAGE__->add_tag_processor(
21 19
     '?'      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
22 20
     '='      => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
23 21
     '<>'     => \&DBIx::Custom::SQL::Template::TagProcessors::expand_basic_tag,
... ...
@@ -31,7 +29,7 @@ $p->add_tag_processor(
31 29
     'update' => \&DBIx::Custom::SQL::Template::TagProcessors::expand_update_tag
32 30
 );
33 31
 
34
-$p->tag_syntax(<< 'EOS');
32
+__PACKAGE__->tag_syntax(<< 'EOS');
35 33
 [tag]                     [expand]
36 34
 {? name}                  ?
37 35
 {= name}                  name = ?
... ...
@@ -54,7 +52,7 @@ EOS
54 52
 sub add_tag_processor {
55 53
     my $invocant = shift;
56 54
     my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
57
-    $invocant->tag_processors(%{$invocant->tag_processors}, %{$tag_processors});
55
+    $invocant->tag_processors({%{$invocant->tag_processors}, %{$tag_processors}});
58 56
     return $invocant;
59 57
 }
60 58
 
+4 -6
lib/DBIx/Custom/SQLite.pm 1000755 → 1000644
... ...
@@ -5,12 +5,10 @@ use strict;
5 5
 use warnings;
6 6
 use Carp 'croak';
7 7
 
8
-my $p = __PACKAGE__;
9
-
10
-$p->add_format(
11
-    datetime => $p->formats->{SQL99_datetime},
12
-    date     => $p->formats->{SQL99_date},
13
-    time     => $p->formats->{SQL99_time},
8
+__PACKAGE__->add_format(
9
+    datetime => __PACKAGE__->formats->{SQL99_datetime},
10
+    date     => __PACKAGE__->formats->{SQL99_date},
11
+    time     => __PACKAGE__->formats->{SQL99_time},
14 12
 );
15 13
 
16 14
 sub connect {
+2 -2
t/dbix-custom-core-sqlite.t 1000755 → 1000644
... ...
@@ -227,8 +227,8 @@ $rows = $result->fetch_hash_all;
227 227
 is_deeply($rows, [{key1 => 2, key2 => 6}], "$test : bind_filter fetch_filter");
228 228
 
229 229
 $dbi->do("delete from table1;");
230
-$insert_query->no_bind_filters('key1');
231
-$select_query->no_fetch_filters('key2');
230
+$insert_query->no_bind_filters(['key1']);
231
+$select_query->no_fetch_filters(['key2']);
232 232
 $dbi->query($insert_query, {key1 => 1, key2 => 2});
233 233
 $result = $dbi->query($select_query);
234 234
 $rows = $result->fetch_hash_all;
+11 -20
t/dbix-custom-core.t
... ...
@@ -53,12 +53,8 @@ test 'Sub class constructor';
53 53
       ->password('b')
54 54
       ->data_source('c')
55 55
       ->options({d => 1, e => 2})
56
-      ->filters(
57
-          f => 3
58
-      )
59
-      ->formats(
60
-          f => 3
61
-      )
56
+      ->filters({f => 3})
57
+      ->formats({f => 3})
62 58
       ->bind_filter('f')
63 59
       ->fetch_filter('g')
64 60
       ->result_class('DBIx::Custom::Result')
... ...
@@ -102,8 +98,8 @@ is($dbi->database, 'a', "$test : database");
102 98
 is($dbi->password, 'b', "$test : password");
103 99
 is($dbi->data_source, 'c', "$test : data_source");
104 100
 is_deeply($dbi->options, {d => 1, e => 2}, "$test : options");
105
-is_deeply({$dbi->filters}, {f => 3}, "$test : filters");
106
-is_deeply({$dbi->formats}, {f => 3}, "$test : formats");
101
+is_deeply($dbi->filters, {f => 3}, "$test : filters");
102
+is_deeply($dbi->formats, {f => 3}, "$test : formats");
107 103
 is($dbi->bind_filter, 'f', "$test : bind_filter");
108 104
 is($dbi->fetch_filter, 'g', "$test : fetch_filter");
109 105
 is($dbi->result_class, 'DBIx::Custom::Result', "$test : result_class");
... ...
@@ -142,12 +138,8 @@ test 'Customized sub class constructor default';
142 138
       ->password('bo')
143 139
       ->data_source('co')
144 140
       ->options({do => 10, eo => 20})
145
-      ->filters(
146
-        fo => 30
147
-      )
148
-      ->formats(
149
-        fo => 30
150
-      )
141
+      ->filters({fo => 30})
142
+      ->formats({fo => 30})
151 143
       ->bind_filter('fo')
152 144
       ->fetch_filter('go')
153 145
       ->result_class('ho')
... ...
@@ -192,8 +184,8 @@ is($dbi->database, 'a', "$test : database");
192 184
 is($dbi->password, 'b', "$test : password");
193 185
 is($dbi->data_source, 'c', "$test : data_source");
194 186
 is_deeply($dbi->options, {d => 1, e => 2}, "$test : options");
195
-is_deeply({$dbi->filters}, {f => 3}, "$test : filters");
196
-is_deeply({$dbi->formats}, {f => 3}, "$test : formats");
187
+is_deeply($dbi->filters, {f => 3}, "$test : filters");
188
+is_deeply($dbi->formats, {f => 3}, "$test : formats");
197 189
 is($dbi->bind_filter, 'f', "$test : bind_filter");
198 190
 is($dbi->fetch_filter, 'g', "$test : fetch_filter");
199 191
 is($dbi->result_class, 'h', "$test : result_class");
... ...
@@ -219,14 +211,13 @@ $dbi->filter_off;
219 211
 ok(!$dbi->bind_filter,  "$test : bind_filter  off");
220 212
 ok(!$dbi->fetch_filter, "$test : fetch_filter off");
221 213
 
222
-__END__
223 214
 test 'Accessor';
224 215
 $dbi = DBIx::Custom->new;
225
-$dbi->options(opt1 => 1, opt2 => 2);
216
+$dbi->options({opt1 => 1, opt2 => 2});
226 217
 is_deeply(scalar $dbi->options, {opt1 => 1, opt2 => 2}, "$test : options");
227 218
 
228
-$dbi->no_bind_filters('a', 'b');
219
+$dbi->no_bind_filters(['a', 'b']);
229 220
 is_deeply(scalar $dbi->no_bind_filters, ['a', 'b'], "$test: no_bind_filters");
230 221
 
231
-$dbi->no_fetch_filters('a', 'b');
222
+$dbi->no_fetch_filters(['a', 'b']);
232 223
 is_deeply(scalar $dbi->no_fetch_filters, ['a', 'b'], "$test: no_fetch_filters");