line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DBIx::Class::FixtureCommand::Populate; { |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1293
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Test::More (); |
5
|
|
|
|
|
|
|
with 'Test::DBIx::Class::Role::FixtureCommand'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub install_fixtures { |
8
|
|
|
|
|
|
|
my ($self, $arg, @rest) = @_; |
9
|
|
|
|
|
|
|
my $builder = $self |
10
|
|
|
|
|
|
|
->schema_manager |
11
|
|
|
|
|
|
|
->builder; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$builder->croak("Argument is required.") |
14
|
|
|
|
|
|
|
unless $arg; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @args; |
17
|
|
|
|
|
|
|
if(ref $arg && ref $arg eq 'ARRAY') { |
18
|
|
|
|
|
|
|
@args = @$arg; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
elsif(ref $arg && ref $arg eq 'HASH') { |
21
|
|
|
|
|
|
|
@args = %$arg; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
else { |
24
|
|
|
|
|
|
|
@args = ($arg, @rest); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my @definitions; |
28
|
|
|
|
|
|
|
while(@args) { |
29
|
|
|
|
|
|
|
my $next = shift(@args); |
30
|
|
|
|
|
|
|
if( (ref $next) && (ref $next eq 'HASH') ) { |
31
|
|
|
|
|
|
|
push @definitions, $next; |
32
|
|
|
|
|
|
|
} else { |
33
|
|
|
|
|
|
|
my $value = shift(@args); |
34
|
|
|
|
|
|
|
push @definitions, {$next => $value}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my @return; |
39
|
|
|
|
|
|
|
foreach my $definition (@definitions) { |
40
|
|
|
|
|
|
|
my ($source, $rows) = each %$definition; |
41
|
|
|
|
|
|
|
my $rs = $self->schema_manager->schema->resultset($source); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my @rows = $rs->populate($rows); |
44
|
|
|
|
|
|
|
push @return, {$source => [@rows]}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
return @return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} 1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |