Showing 3 changed files with 20 additions and 21 deletions
+1 -1
Changes
... ...
@@ -1,6 +1,6 @@
1 1
 0.1638
2 2
   added experimental base_table attribute and  removed experimental table_class attribute
3
-  renamed helper to method. helper is available, but deprecated.
3
+  renamed helper to method.
4 4
   added experimental DBIx::Custom::Result::stash()
5 5
   renamed experimental DBIx::Custom::Table helper to method
6 6
 0.1637
+14 -15
lib/DBIx/Custom.pm
... ...
@@ -69,16 +69,15 @@ our $AUTOLOAD;
69 69
 sub AUTOLOAD {
70 70
     my $self = shift;
71 71
 
72
-    # Method
73
-    my ($package, $method) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
74
-
75
-    # Helper
76
-    $self->{_helpers} ||= {};
77
-    croak qq/Can't locate object method "$method" via "$package"/
78
-      unless my $helper = $self->{_helpers}->{$method};
72
+    # Method name
73
+    my ($package, $mname) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
79 74
 
80
-    # Run
81
-    return $self->$helper(@_);
75
+    # Method
76
+    $self->{_methods} ||= {};
77
+    croak qq/Can't locate object method "$mname" via "$package"/
78
+      unless my $method = $self->{_methods}->{$mname};
79
+    
80
+    return $self->$method(@_);
82 81
 }
83 82
 
84 83
 sub apply_filter {
... ...
@@ -145,12 +144,12 @@ sub apply_filter {
145 144
     return $self;
146 145
 }
147 146
 
148
-sub helper {
147
+sub method {
149 148
     my $self = shift;
150 149
     
151 150
     # Merge
152
-    my $helpers = ref $_[0] eq 'HASH' ? $_[0] : {@_};
153
-    $self->{_helpers} = {%{$self->{_helpers} || {}}, %$helpers};
151
+    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
152
+    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
154 153
     
155 154
     return $self;
156 155
 }
... ...
@@ -1074,9 +1073,9 @@ Arguments is same as C<delete> method,
1074 1073
 except that C<delete_all> don't have C<where> argument.
1075 1074
 Return value of C<delete_all()> is the count of affected rows.
1076 1075
 
1077
-=head2 C<(experimental) helper>
1076
+=head2 C<(experimental) method>
1078 1077
 
1079
-    $dbi->helper(
1078
+    $dbi->method(
1080 1079
         update_or_insert => sub {
1081 1080
             my $self = shift;
1082 1081
             # do something
... ...
@@ -1087,7 +1086,7 @@ Return value of C<delete_all()> is the count of affected rows.
1087 1086
         }
1088 1087
     );
1089 1088
 
1090
-Register helper methods. These method is called from L<DBIx::Custom> object directory.
1089
+Register method. These method is called from L<DBIx::Custom> object directory.
1091 1090
 
1092 1091
     $dbi->update_or_insert;
1093 1092
     $dbi->find_or_create;
+5 -5
t/dbix-custom-core-sqlite.t
... ...
@@ -525,15 +525,15 @@ ok($@, "exception");
525 525
 $dbi->dbh->{AutoCommit} = 1;
526 526
 
527 527
 
528
-test 'helper';
528
+test 'method';
529 529
 $dbi = DBIx::Custom->connect($NEW_ARGS->{0});
530
-$dbi->helper(
530
+$dbi->method(
531 531
     one => sub { 1 }
532 532
 );
533
-$dbi->helper(
533
+$dbi->method(
534 534
     two => sub { 2 }
535 535
 );
536
-$dbi->helper({
536
+$dbi->method({
537 537
     twice => sub {
538 538
         my $self = shift;
539 539
         return $_[0] * 2;
... ...
@@ -1003,7 +1003,7 @@ eval {$dbi->apply_filter('table1', 'key2', {out => 'no'})};
1003 1003
 like($@, qr/not registered/);
1004 1004
 eval {$dbi->apply_filter('table1', 'key2', {in => 'no'})};
1005 1005
 like($@, qr/not registered/);
1006
-$dbi->helper({one => sub { 1 }});
1006
+$dbi->method({one => sub { 1 }});
1007 1007
 is($dbi->one, 1);
1008 1008
 
1009 1009
 eval{DBIx::Custom->connect()};