line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Aniki::Result::Collection; |
2
|
27
|
|
|
27
|
|
546
|
use 5.014002; |
|
27
|
|
|
|
|
100
|
|
3
|
|
|
|
|
|
|
|
4
|
27
|
|
|
27
|
|
159
|
use namespace::autoclean; |
|
27
|
|
|
|
|
278
|
|
|
27
|
|
|
|
|
190
|
|
5
|
27
|
|
|
27
|
|
2029
|
use Mouse v2.4.5; |
|
27
|
|
|
|
|
506
|
|
|
27
|
|
|
|
|
192
|
|
6
|
|
|
|
|
|
|
extends qw/Aniki::Result/; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use overload |
9
|
0
|
|
|
0
|
|
0
|
'@{}' => sub { shift->rows }, |
10
|
27
|
|
|
27
|
|
39491
|
fallback => 1; |
|
27
|
|
|
|
|
25002
|
|
|
27
|
|
|
|
|
238
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has row_datas => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
required => 1, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has inflated_rows => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
lazy => 1, |
20
|
|
|
|
|
|
|
builder => '_inflate', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _inflate { |
24
|
65
|
|
|
65
|
|
149
|
my $self = shift; |
25
|
65
|
|
|
|
|
485
|
my $row_class = $self->row_class; |
26
|
65
|
|
|
|
|
550
|
my $table_name = $self->table_name; |
27
|
65
|
|
|
|
|
272
|
my $handler = $self->handler; |
28
|
|
|
|
|
|
|
return [ |
29
|
|
|
|
|
|
|
map { |
30
|
125
|
|
|
|
|
1206
|
$row_class->new( |
31
|
|
|
|
|
|
|
table_name => $table_name, |
32
|
|
|
|
|
|
|
handler => $handler, |
33
|
|
|
|
|
|
|
row_data => $_ |
34
|
|
|
|
|
|
|
) |
35
|
65
|
|
|
|
|
143
|
} @{ $self->row_datas } |
|
65
|
|
|
|
|
293
|
|
36
|
|
|
|
|
|
|
]; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub rows { |
40
|
148
|
|
|
148
|
1
|
377
|
my $self = shift; |
41
|
148
|
100
|
|
|
|
1443
|
return $self->suppress_row_objects ? $self->row_datas : $self->inflated_rows; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
72
|
|
|
72
|
1
|
22956
|
sub count { scalar @{ shift->rows(@_) } } |
|
72
|
|
|
|
|
284
|
|
45
|
|
|
|
|
|
|
|
46
|
21
|
|
|
21
|
1
|
114
|
sub first { shift->rows(@_)->[0] } |
47
|
0
|
|
|
0
|
1
|
0
|
sub last :method { shift->rows(@_)->[-1] } |
48
|
45
|
|
|
45
|
1
|
8964
|
sub all { @{ shift->rows(@_) } } |
|
45
|
|
|
|
|
123
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding utf-8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Aniki::Result::Collection - Rows as a collection |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $result = $db->select(foo => { bar => 1 }); |
64
|
|
|
|
|
|
|
for my $row ($result->all) { |
65
|
|
|
|
|
|
|
print $row->id, "\n"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This is collection result class. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 INSTANCE METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 C<rows()> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns rows as array reference. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 C<count()> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns rows count. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 C<first()> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns first row. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 C<last()> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns last row. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 C<all()> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns rows as array. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 ACCESSORS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over 4 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item C<handler : Aniki> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item C<table_name : Str> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item C<suppress_row_objects : Bool> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item C<row_class : ClassName> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item C<row_datas : ArrayRef[HashRef]> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item C<inflated_rows : ArrayRef[Aniki::Row]> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 LICENSE |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Copyright (C) karupanerura. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
117
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
karupanerura E<lt>karupa@cpan.orgE<gt> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |