File Coverage

blib/lib/Rethinkdb/Base.pm
Criterion Covered Total %
statement 60 1383 4.3
branch 20 1058 1.8
condition 5 12 41.6
subroutine 12 281 4.2
pod 30 30 100.0
total 127 2764 4.5


line stmt bran cond sub pod time code
1             package Rethinkdb::Base;
2              
3 15     15   58 use strict;
  15         18  
  15         356  
4 15     15   60 use warnings;
  15         13  
  15         284  
5 15     15   7141 use utf8;
  15         117  
  15         54  
6 15     15   336 use feature ();
  15         17  
  15         171  
7              
8             # No imports because we get subclassed, a lot!
9 15     15   41 use Carp ();
  15         15  
  15         144  
10              
11             # Only Perl 5.14+ requires it on demand
12 15     15   6691 use IO::Handle ();
  15         69270  
  15         517  
13              
14             sub import {
15 615     615   737 my $class = shift;
16 615 100       134844 return unless my $flag = shift;
17 15     15   68 no strict 'refs';
  15         20  
  15         5174  
18              
19             # Base
20 375 100       635 if ( $flag eq '-base' ) { $flag = $class }
  330 50       340  
21              
22             # Strict
23 0         0 elsif ( $flag eq '-strict' ) { $flag = undef }
24              
25             # Module
26             else {
27 45         56 my $file = $flag;
28 45         308 $file =~ s/::|'/\//g;
29 45 100       6929 require "$file.pm" unless $flag->can('new');
30             }
31              
32             # ISA
33 375 50       567 if ($flag) {
34 375         468 my $caller = caller;
35 375         265 push @{"${caller}::ISA"}, $flag;
  375         2836  
36 375     3795   1083 *{"${caller}::has"} = sub { attr( $caller, @_ ) };
  375         1196  
  3795         5878  
37             }
38              
39             # Mojo modules are strict!
40 375         1284 strict->import;
41 375         2493 warnings->import;
42 375         844 utf8->import;
43 375         45617 feature->import(':5.10');
44             }
45              
46             sub new {
47 15     15 1 32 my $class = shift;
48 15 0 33     137 bless @_ ? @_ > 1 ? {@_} : { %{ $_[0] } } : {}, ref $class || $class;
  0 50       0  
49             }
50              
51             # Performance is very important for something as often used as accessors,
52             # so we optimize them by compiling our own code, don't be scared, we have
53             # tests for every single case
54             sub attr {
55 3795     3795 1 4186 my ( $class, $attrs, $default ) = @_;
56 3795 50 33     18971 return unless ( $class = ref $class || $class ) && $attrs;
      33        
57              
58 3795 50 66     6216 Carp::croak 'Default has to be a code reference or constant value'
59             if ref $default && ref $default ne 'CODE';
60              
61             # Compile attributes
62 3795 100       2770 for my $attr ( @{ ref $attrs eq 'ARRAY' ? $attrs : [$attrs] } ) {
  3795         8868  
63 4020 50       9952 Carp::croak qq{Attribute "$attr" invalid} unless $attr =~ /^[a-zA-Z_]\w*$/;
64              
65             # Header (check arguments)
66 4020         6751 my $code = "package $class;\nsub $attr {\n if (\@_ == 1) {\n";
67              
68             # No default value (return value)
69 4020 100       4859 unless ( defined $default ) { $code .= " return \$_[0]{'$attr'};" }
  330         425  
70              
71             # Default value
72             else {
73              
74             # Return value
75 3690         4370 $code .= " return \$_[0]{'$attr'} if exists \$_[0]{'$attr'};\n";
76              
77             # Return default value
78 3690         3380 $code .= " return \$_[0]{'$attr'} = ";
79 3690 100       4659 $code .= ref $default eq 'CODE' ? '$default->($_[0]);' : '$default;';
80             }
81              
82             # Store value
83 4020         3812 $code .= "\n }\n \$_[0]{'$attr'} = \$_[1];\n";
84              
85             # Footer (return invocant)
86 4020         2853 $code .= " \$_[0];\n}";
87              
88             # We compile custom attribute code for speed
89 15     15   67 no strict 'refs';
  15         19  
  15         2120  
90 4020 50       6147 warn "-- Attribute $attr in $class\n$code\n\n" if $ENV{RDB_BASE_DEBUG};
91 4020 50   0 1 379785 Carp::croak "Rethinkdb::Base error: $@" unless eval "$code;1";
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0 1    
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0   0      
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0 0          
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
  0            
92             }
93             }
94              
95             sub tap {
96 0     0 1   my ( $self, $cb ) = @_;
97 0           $_->$cb for $self;
98 0           return $self;
99             }
100              
101             1;
102              
103             =head1 NAME
104              
105             Rethinkdb::Base - Minimal base class
106              
107             =head1 SYNOPSIS
108              
109             package Cat;
110             use Rethinkdb::Base -base;
111              
112             has name => 'Nyan';
113             has [qw(birds mice)] => 2;
114              
115             package Tiger;
116             use Rethinkdb::Base 'Cat';
117              
118             has friend => sub { Cat->new };
119             has stripes => 42;
120              
121             package main;
122             use Rethinkdb::Base -strict;
123              
124             my $mew = Cat->new(name => 'Longcat');
125             say $mew->mice;
126             say $mew->mice(3)->birds(4)->mice;
127              
128             my $rawr = Tiger->new(stripes => 23, mice => 0);
129             say $rawr->tap(sub { $_->friend->name('Tacgnol') })->mice;
130              
131             =head1 DESCRIPTION
132              
133             L is a simple base class.
134              
135             # Automatically enables "strict", "warnings", "utf8" and Perl 5.10 features
136             use Rethinkdb::Base -strict;
137             use Rethinkdb::Base -base;
138             use Rethinkdb::Base 'SomeBaseClass';
139              
140             All three forms save a lot of typing.
141              
142             # use Rethinkdb::Base -strict;
143             use strict;
144             use warnings;
145             use utf8;
146             use feature ':5.10';
147             use IO::Handle ();
148              
149             # use Rethinkdb::Base -base;
150             use strict;
151             use warnings;
152             use utf8;
153             use feature ':5.10';
154             use IO::Handle ();
155             use Rethinkdb::Base;
156             push @ISA, 'Rethinkdb::Base';
157             sub has { Rethinkdb::Base::attr(__PACKAGE__, @_) }
158              
159             # use Rethinkdb::Base 'SomeBaseClass';
160             use strict;
161             use warnings;
162             use utf8;
163             use feature ':5.10';
164             use IO::Handle ();
165             require SomeBaseClass;
166             push @ISA, 'SomeBaseClass';
167             use Rethinkdb::Base;
168             sub has { Rethinkdb::Base::attr(__PACKAGE__, @_) }
169              
170             =head1 FUNCTIONS
171              
172             L exports the following functions if imported with the C<-base>
173             flag or a base class.
174              
175             =head2 has
176              
177             has 'name';
178             has [qw(name1 name2 name3)];
179             has name => 'foo';
180             has name => sub {...};
181             has [qw(name1 name2 name3)] => 'foo';
182             has [qw(name1 name2 name3)] => sub {...};
183              
184             Create attributes for hash-based objects, just like the C method.
185              
186             =head1 METHODS
187              
188             L implements the following methods.
189              
190             =head2 new
191              
192             my $object = BaseSubClass->new;
193             my $object = BaseSubClass->new(name => 'value');
194             my $object = BaseSubClass->new({name => 'value'});
195              
196             This base class provides a basic constructor for hash-based objects. You can
197             pass it either a hash or a hash reference with attribute values.
198              
199             =head2 attr
200              
201             $object->attr('name');
202             BaseSubClass->attr('name');
203             BaseSubClass->attr([qw(name1 name2 name3)]);
204             BaseSubClass->attr(name => 'foo');
205             BaseSubClass->attr(name => sub {...});
206             BaseSubClass->attr([qw(name1 name2 name3)] => 'foo');
207             BaseSubClass->attr([qw(name1 name2 name3)] => sub {...});
208              
209             Create attribute accessor for hash-based objects, an array reference can be
210             used to create more than one at a time. Pass an optional second argument to
211             set a default value, it should be a constant or a callback. The callback will
212             be excuted at accessor read time if there's no set value. Accessors can be
213             chained, that means they return their invocant when they are called with an
214             argument.
215              
216             =head2 tap
217              
218             $object = $object->tap(sub {...});
219              
220             K combinator, tap into a method chain to perform operations on an object
221             within the chain.
222              
223             =head1 DEBUGGING
224              
225             You can set the RDB_BASE_DEBUG environment variable to get some advanced
226             diagnostics information printed to C.
227              
228             RDB_BASE_DEBUG=1
229              
230             =head1 COPYRIGHT AND LICENSE
231              
232             This package was taken from the Mojolicious project.
233              
234             Copyright (C) 2008-2013, Sebastian Riedel.
235              
236             =head1 SEE ALSO
237              
238             L, L, L.
239              
240             =cut