| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::Skinny::ProxyTable::Rule; |
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
20
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use Carp qw(); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
637
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
|
7
|
0
|
|
|
0
|
0
|
|
my ($class, $proxy_table, $base, @args) = @_; |
|
8
|
0
|
|
|
|
|
|
my $self = { |
|
9
|
|
|
|
|
|
|
proxy_table => $proxy_table, |
|
10
|
|
|
|
|
|
|
base_table => $base, |
|
11
|
|
|
|
|
|
|
}; |
|
12
|
0
|
|
|
|
|
|
bless $self, $class; |
|
13
|
0
|
|
|
|
|
|
$self->{table_name} = $self->_table_name(@args); |
|
14
|
0
|
|
|
|
|
|
$self->{proxy_table}->set($self->{base_table}, $self->table_name); |
|
15
|
0
|
|
|
|
|
|
return $self; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub table_name { |
|
19
|
0
|
|
|
0
|
0
|
|
my $self = $_[0]; |
|
20
|
0
|
|
|
|
|
|
$self->{table_name}; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _table_name { |
|
24
|
0
|
|
|
0
|
|
|
my ($self, @args) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $rule = $self->{proxy_table}->{skinny}->schema->proxy_table_rules->{$self->{base_table}}; |
|
27
|
0
|
0
|
|
|
|
|
unless ( $rule ) { |
|
28
|
0
|
|
|
|
|
|
Carp::croak("Cant' find proxy_table_rules for @{[ $self->{base_table} ]}"); |
|
|
0
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
0
|
|
|
|
|
|
my ($func, @default_args) = @{$rule}; |
|
|
0
|
|
|
|
|
|
|
|
31
|
0
|
0
|
0
|
|
|
|
if ( ref $func && ref $func eq "CODE" ) { |
|
32
|
0
|
|
|
|
|
|
return $func->(@default_args, @args); |
|
33
|
|
|
|
|
|
|
} else { |
|
34
|
0
|
|
|
|
|
|
return $self->$func(@default_args, @args); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub copy_table { |
|
39
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
|
40
|
0
|
|
|
|
|
|
$self->{proxy_table}->copy_table($self->{base_table}, $self->table_name); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub strftime { |
|
44
|
0
|
|
|
0
|
0
|
|
my ($self, $tmpl, $dt) = @_; |
|
45
|
0
|
|
|
|
|
|
$dt->strftime($tmpl); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub named_strftime { |
|
49
|
0
|
|
|
0
|
0
|
|
my ($self, $tmpl, $key, %args) = @_; |
|
50
|
0
|
0
|
|
|
|
|
if ( $args{$key} ) { |
|
51
|
0
|
|
|
|
|
|
return $args{$key}->strftime($tmpl); |
|
52
|
|
|
|
|
|
|
} else { |
|
53
|
0
|
|
|
|
|
|
Carp::croak("can't find key $key for argument"); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub sprintf { |
|
58
|
0
|
|
|
0
|
0
|
|
my ($self, $tmpl, @args) = @_; |
|
59
|
0
|
|
|
|
|
|
CORE::sprintf($tmpl, @args); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub keyword { |
|
63
|
0
|
|
|
0
|
0
|
|
my ($self, $tmpl, %args) = @_; |
|
64
|
0
|
|
|
|
|
|
my @binds; |
|
65
|
0
|
|
|
|
|
|
$tmpl =~ s{<(%[^:]+):([A-Za-z_][A-Za-z0-9_]*)>}{ |
|
66
|
0
|
0
|
|
|
|
|
Carp::croak("$2 is not exists in hash") if !exists $args{$2}; |
|
67
|
0
|
|
|
|
|
|
push @binds, $args{$2}; |
|
68
|
0
|
|
|
|
|
|
$1 |
|
69
|
|
|
|
|
|
|
}ge; |
|
70
|
0
|
|
|
|
|
|
return CORE::sprintf($tmpl, @binds); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
|
74
|
|
|
|
|
|
|
__END__ |