Showing 3 changed files with 8 additions and 0 deletions
+2
Changes
... ...
@@ -1,4 +1,6 @@
1 1
 0.1722
2
+    - added {KEY => sub { VALUE }} syntax
3
+      to EXPERIMETNAL DBIx::Custom::Mapper map method
2 4
     - removed EXPERIMENTAL wrap option from select method
3 5
     - insert_param, update_param, and assign param can
4 6
       be wrapeed by DB function by C<wrap> option
+1
lib/DBIx/Custom/Mapper.pm
... ...
@@ -29,6 +29,7 @@ sub map {
29 29
         my $new_key;
30 30
         
31 31
         # Get mapping information
32
+        $rule{$key} = [$key, $rule{$key}] if ref $rule{$key} eq 'CODE';
32 33
         if (ref $rule{$key} eq 'ARRAY') {
33 34
             foreach my $some (@{$rule{$key}}) {
34 35
                 $new_key = $some unless ref $some;
+5
t/common.t
... ...
@@ -2663,6 +2663,11 @@ $param = $dbi->mapper(param => {price => 'a'}, condition => 'exists')->map(
2663 2663
 );
2664 2664
 is_deeply($param, {"$table1.price" => '%a'});
2665 2665
 
2666
+$param = $dbi->mapper(param => {price => 'a'})->map(
2667
+    price => sub { '%' . $_[0] }
2668
+);
2669
+is_deeply($param, {price => '%a'});
2670
+
2666 2671
 eval { $dbi->execute("drop table $table1") };
2667 2672
 $dbi->execute($create_table1);
2668 2673
 $dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});