line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#ABSTRACT: Light ORM for Dancer |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Dancer::Plugin::ORMesque; |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
2675793
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
379
|
|
6
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
277
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
31
|
use Dancer qw/:syntax/; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
37
|
|
9
|
6
|
|
|
6
|
|
9352
|
use Dancer::Plugin; |
|
6
|
|
|
|
|
10105
|
|
|
6
|
|
|
|
|
592
|
|
10
|
6
|
|
|
6
|
|
6806
|
use ORMesque; |
|
6
|
|
|
|
|
703403
|
|
|
6
|
|
|
|
|
2148
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '1.113100'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $schemas = {}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
register db => sub { |
18
|
0
|
|
|
0
|
|
|
my $name = shift; |
19
|
0
|
|
|
|
|
|
my $cfg = plugin_setting; |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
if (not defined $name) { |
22
|
0
|
0
|
|
|
|
|
($name) = keys %$cfg or die "No schemas are configured"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
return $schemas->{$name} if $schemas->{$name}; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
my $options = $cfg->{$name} or die "The schema $name is not configured"; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my @conn_info = $options->{connect_info} |
30
|
0
|
0
|
|
|
|
|
? @{$options->{connect_info}} |
31
|
|
|
|
|
|
|
: @$options{qw(dsn user pass options)}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# pckg should be deprecated |
34
|
0
|
|
0
|
|
|
|
my $schema_class = $options->{schema_class} || $options->{pckg}; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ($schema_class) { |
37
|
0
|
|
|
|
|
|
$schema_class =~ s/-/::/g; |
38
|
0
|
|
|
|
|
|
eval "use $schema_class"; |
39
|
0
|
0
|
|
|
|
|
if ( my $err = $@ ) { |
40
|
0
|
|
|
|
|
|
die "error while loading $schema_class : $err"; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
$schemas->{$name} = $schema_class->new(@conn_info) |
43
|
|
|
|
|
|
|
} else { |
44
|
0
|
|
|
|
|
|
$schemas->{$name} = ORMesque->new(@conn_info); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $schemas->{$name}; |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
register_plugin; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |