line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Curio::Role::DBIx::Connector; |
2
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
565347
|
use DBIx::Connector; |
|
2
|
|
|
|
|
41192
|
|
|
2
|
|
|
|
|
80
|
|
5
|
2
|
|
|
2
|
|
16
|
use Scalar::Util qw( blessed ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
107
|
|
6
|
2
|
|
|
2
|
|
12
|
use Types::Standard qw( InstanceOf ArrayRef ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1385
|
use Moo::Role; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
9
|
2
|
|
|
2
|
|
670
|
use strictures 2; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
71
|
|
10
|
2
|
|
|
2
|
|
387
|
use namespace::clean; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Curio::Role'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
after initialize => sub{ |
15
|
|
|
|
|
|
|
my ($class) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $factory = $class->factory(); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$factory->does_caching( 1 ); |
20
|
|
|
|
|
|
|
$factory->resource_method_name( 'connector' ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has _custom_connector => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => InstanceOf[ 'DBIx::Connector' ] | ArrayRef, |
28
|
|
|
|
|
|
|
init_arg => 'connector', |
29
|
|
|
|
|
|
|
clearer => '_clear_custom_connector', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has connector => ( |
33
|
|
|
|
|
|
|
is => 'lazy', |
34
|
|
|
|
|
|
|
init_arg => undef, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _build_connector { |
38
|
3
|
|
|
3
|
|
16489
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
10
|
my $connector = $self->_custom_connector(); |
41
|
3
|
|
|
|
|
46
|
$self->_clear_custom_connector(); |
42
|
3
|
50
|
|
|
|
25
|
return $connector if blessed $connector; |
43
|
|
|
|
|
|
|
|
44
|
3
|
50
|
|
|
|
18
|
return DBIx::Connector->new( @$connector ) if $connector; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
19
|
my $dsn = $self->dsn(); |
47
|
3
|
100
|
|
|
|
1856
|
my $username = $self->can('username') ? $self->username() : ''; |
48
|
3
|
100
|
|
|
|
194
|
my $password = $self->can('password') ? $self->password() : ''; |
49
|
3
|
50
|
|
|
|
1997
|
my $attributes = $self->can('attributes') ? $self->attributes() : {}; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
29
|
return DBIx::Connector->new( |
52
|
|
|
|
|
|
|
$dsn, |
53
|
|
|
|
|
|
|
$username, |
54
|
|
|
|
|
|
|
$password, |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
AutoCommit => 1, |
57
|
|
|
|
|
|
|
%$attributes, |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |