line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Curio::Role::DBIx::Connector; |
2
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
552835
|
use DBIx::Connector; |
|
2
|
|
|
|
|
37145
|
|
|
2
|
|
|
|
|
63
|
|
5
|
2
|
|
|
2
|
|
15
|
use Scalar::Util qw( blessed ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
102
|
|
6
|
2
|
|
|
2
|
|
12
|
use Types::Standard qw( InstanceOf ArrayRef ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
19
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1219
|
use Moo::Role; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
17
|
|
9
|
2
|
|
|
2
|
|
668
|
use strictures 2; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
66
|
|
10
|
2
|
|
|
2
|
|
390
|
use namespace::clean; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
16
|
|
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
|
|
15665
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
9
|
my $connector = $self->_custom_connector(); |
41
|
3
|
|
|
|
|
45
|
$self->_clear_custom_connector(); |
42
|
3
|
50
|
|
|
|
21
|
return $connector if blessed $connector; |
43
|
|
|
|
|
|
|
|
44
|
3
|
50
|
|
|
|
23
|
return DBIx::Connector->new( @$connector ) if $connector; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
16
|
my $dsn = $self->dsn(); |
47
|
3
|
100
|
|
|
|
1571
|
my $username = $self->can('username') ? $self->username() : ''; |
48
|
3
|
100
|
|
|
|
165
|
my $password = $self->can('password') ? $self->password() : ''; |
49
|
3
|
50
|
|
|
|
1756
|
my $attributes = $self->can('attributes') ? $self->attributes() : {}; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
33
|
return DBIx::Connector->new( |
52
|
|
|
|
|
|
|
$dsn, |
53
|
|
|
|
|
|
|
$username, |
54
|
|
|
|
|
|
|
$password, |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
AutoCommit => 1, |
57
|
|
|
|
|
|
|
%$attributes, |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |