Showing 2 changed files with 44 additions and 49 deletions
+43 -48
lib/DBIx/Custom/Result.pm
... ...
@@ -47,43 +47,6 @@ sub filter {
47 47
     return $self->{filter} ||= {};
48 48
 }
49 49
 
50
-sub end_filter {
51
-    my $self = shift;
52
-    
53
-    if (@_) {
54
-        my $end_filter = {};
55
-        
56
-        if (ref $_[0] eq 'HASH') {
57
-            $end_filter = $_[0];
58
-        }
59
-        else {
60
-            $end_filter = _array_to_hash(
61
-                @_ > 1 ? [@_] : $_[0]
62
-            );
63
-        }
64
-        
65
-        foreach my $column (keys %$end_filter) {
66
-            my $fname = $end_filter->{$column};
67
-            
68
-            if  (exists $end_filter->{$column}
69
-              && defined $fname
70
-              && ref $fname ne 'CODE') 
71
-            {
72
-              croak qq{Filter "$fname" is not registered" } . _subname
73
-                unless exists $self->filters->{$fname};
74
-              
75
-              $end_filter->{$column} = $self->filters->{$fname};
76
-            }
77
-        }
78
-        
79
-        $self->{end_filter} = {%{$self->end_filter}, %$end_filter};
80
-        
81
-        return $self;
82
-    }
83
-    
84
-    return $self->{end_filter} ||= {};
85
-}
86
-
87 50
 sub fetch {
88 51
     my $self = shift;
89 52
     
... ...
@@ -91,7 +54,7 @@ sub fetch {
91 54
     my $filter = $self->filter;
92 55
     
93 56
     # End filter
94
-    my $end_filter = $self->end_filter;
57
+    my $end_filter = $self->{end_filter} || {};
95 58
     
96 59
     # Fetch
97 60
     my @row = $self->{sth}->fetchrow_array;
... ...
@@ -116,7 +79,7 @@ sub fetch {
116 79
         my $column = $columns->[$i];
117 80
         my $f  = exists $filter->{$column}
118 81
                ? $filter->{$column}
119
-               : $self->_default_filter;
82
+               : $self->{default_filter};
120 83
         my $ef = $end_filter->{$column};
121 84
         
122 85
         # Filtering
... ...
@@ -160,7 +123,7 @@ sub fetch_hash {
160 123
     my $filter  = $self->filter;
161 124
     
162 125
     # End filter
163
-    my $end_filter = $self->end_filter;
126
+    my $end_filter = $self->{end_filter} || {};
164 127
     
165 128
     # Fetch
166 129
     my $row = $self->{sth}->fetchrow_arrayref;
... ...
@@ -186,7 +149,7 @@ sub fetch_hash {
186 149
         my $column = $columns->[$i];
187 150
         my $f  = exists $filter->{$column}
188 151
                ? $filter->{$column}
189
-               : $self->_default_filter;
152
+               : $self->{default_filter};
190 153
         my $ef = $end_filter->{$column};
191 154
         
192 155
         # Filtering
... ...
@@ -266,6 +229,44 @@ sub fetch_multi {
266 229
 
267 230
 *one = \&fetch_hash_first;
268 231
 
232
+# DEPRECATED!
233
+sub end_filter {
234
+    my $self = shift;
235
+    
236
+    if (@_) {
237
+        my $end_filter = {};
238
+        
239
+        if (ref $_[0] eq 'HASH') {
240
+            $end_filter = $_[0];
241
+        }
242
+        else {
243
+            $end_filter = _array_to_hash(
244
+                @_ > 1 ? [@_] : $_[0]
245
+            );
246
+        }
247
+        
248
+        foreach my $column (keys %$end_filter) {
249
+            my $fname = $end_filter->{$column};
250
+            
251
+            if  (exists $end_filter->{$column}
252
+              && defined $fname
253
+              && ref $fname ne 'CODE') 
254
+            {
255
+              croak qq{Filter "$fname" is not registered" } . _subname
256
+                unless exists $self->filters->{$fname};
257
+              
258
+              $end_filter->{$column} = $self->filters->{$fname};
259
+            }
260
+        }
261
+        
262
+        $self->{end_filter} = {%{$self->end_filter}, %$end_filter};
263
+        
264
+        return $self;
265
+    }
266
+    
267
+    return $self->{end_filter} ||= {};
268
+}
269
+
269 270
 # DEPRECATED!
270 271
 sub remove_end_filter {
271 272
     my $self = shift;
... ...
@@ -291,14 +292,8 @@ sub remove_filter {
291 292
 # DEPRECATED!
292 293
 sub default_filter {
293 294
     my $self = shift;
294
-    warn "default_filter is DEPRECATED!";
295
-    return $self->_default_filter(@_)
296
-}
297
-
298
-# DEPRECATED!
299
-sub _default_filter {
300
-    my $self = shift;
301 295
 
296
+    warn "default_filter is DEPRECATED!";
302 297
     
303 298
     if (@_) {
304 299
         my $fname = $_[0];
+1 -1
t/dbix-custom-core-sqlite.t
... ...
@@ -6,7 +6,7 @@ use utf8;
6 6
 use Encode qw/encode_utf8 decode_utf8/;
7 7
 use Data::Dumper;
8 8
 
9
-$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
9
+#$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
10 10
 
11 11
 BEGIN {
12 12
     eval { require DBD::SQLite; 1 }