line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
35
|
use 5.006; |
|
2
|
|
|
|
|
7
|
|
2
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
45
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
117
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
7
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Class::Tiny; |
10
|
2
|
|
|
2
|
|
939
|
use parent qw( LINQ::FieldSet ); |
|
2
|
|
|
|
|
3683
|
|
|
2
|
|
|
|
|
10
|
|
11
|
2
|
|
|
2
|
|
136
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
12
|
|
|
|
|
|
|
use overload ( |
13
|
|
|
|
|
|
|
'fallback' => !!1, |
14
|
|
|
|
|
|
|
q[bool] => sub { !! 1 }, |
15
|
0
|
|
|
0
|
|
0
|
q[""] => 'to_string', |
16
|
2
|
|
|
|
|
18
|
q[&{}] => 'coderef', |
17
|
|
|
|
|
|
|
); |
18
|
2
|
|
|
2
|
|
150
|
|
|
2
|
|
|
|
|
5
|
|
19
|
|
|
|
|
|
|
my ( $self ) = ( shift ); |
20
|
|
|
|
|
|
|
|
21
|
11
|
|
|
11
|
|
23
|
return ( |
22
|
|
|
|
|
|
|
$self->SUPER::_known_parameter_names, |
23
|
|
|
|
|
|
|
'as' => 1, |
24
|
11
|
|
|
|
|
37
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my ( $self ) = ( shift ); |
28
|
|
|
|
|
|
|
$self->{target_class} ||= $self->_build_target_class; |
29
|
|
|
|
|
|
|
} |
30
|
10
|
|
|
10
|
1
|
3342
|
|
31
|
10
|
|
100
|
|
|
57
|
my ( $self ) = ( shift ); |
32
|
|
|
|
|
|
|
require Object::Adhoc; |
33
|
|
|
|
|
|
|
return Object::Adhoc::make_class( [ keys %{ $self->fields_hash } ] ); |
34
|
|
|
|
|
|
|
} |
35
|
7
|
|
|
7
|
|
13
|
|
36
|
7
|
|
|
|
|
32
|
my ( $self ) = ( shift ); |
37
|
7
|
|
|
|
|
13
|
$self->{coderef} ||= $self->_build_coderef; |
|
7
|
|
|
|
|
27
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my ( $self ) = ( shift ); |
41
|
13
|
|
|
13
|
1
|
1348
|
my @fields = @{ $self->fields }; |
42
|
13
|
|
100
|
|
|
51
|
my $bless = $self->target_class; |
43
|
|
|
|
|
|
|
my $asterisk = $self->seen_asterisk; |
44
|
|
|
|
|
|
|
return sub { |
45
|
|
|
|
|
|
|
my %output = (); |
46
|
6
|
|
|
6
|
|
11
|
if ( $asterisk ) { |
47
|
6
|
|
|
|
|
12
|
%output = %$_; |
|
6
|
|
|
|
|
148
|
|
48
|
6
|
|
|
|
|
48
|
} |
49
|
6
|
|
|
|
|
1552
|
for my $field ( @fields ) { |
50
|
|
|
|
|
|
|
$output{ $field->name } = $field->getter->( $_ ); |
51
|
11
|
|
|
11
|
|
20
|
} |
52
|
11
|
100
|
|
|
|
25
|
$asterisk ? Object::Adhoc::object( \%output ) : bless( \%output, $bless ); |
53
|
1
|
|
|
|
|
4
|
}; |
54
|
|
|
|
|
|
|
} #/ sub _build_coderef |
55
|
11
|
|
|
|
|
24
|
|
56
|
26
|
|
|
|
|
138
|
my ( $self ) = ( shift ); |
57
|
|
|
|
|
|
|
sprintf 'fields(%s)', join q[, ], map $_->name, @{ $self->fields }; |
58
|
11
|
100
|
|
|
|
233
|
} |
59
|
6
|
|
|
|
|
67
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
1
|
20
|
=pod |
64
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
23
|
|
65
|
|
|
|
|
|
|
=encoding utf-8 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
LINQ::FieldSet::Selection - represents an SQL-SELECT-like transformation |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
LINQ::FieldSet::Selection is a subclass of L<LINQ::FieldSet>. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This is used internally by LINQ and you probably don't need to know about it |
76
|
|
|
|
|
|
|
unless you're writing very specific extensions for LINQ. The end user |
77
|
|
|
|
|
|
|
interface is the C<fields> function in L<LINQ::Util>. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item C<< new( ARGSLIST ) >> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Constructs a fieldset from a list of fields like: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
'LINQ::FieldSet::Selection'->new( |
88
|
|
|
|
|
|
|
'field1', -param1 => 'value1', -param2, |
89
|
|
|
|
|
|
|
'field2', -param1 => 'value2', |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Allowed parameters are: |
93
|
|
|
|
|
|
|
C<< -as >> (followed by a value). |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item C<target_class> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The class data selected by this selection will be blessed into. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item C<coderef> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Gets a coderef for this assertion; the coderef operates on C<< $_ >>. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item C<to_string> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Basic string representation of the fieldset. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 OVERLOADING |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This class overloads |
118
|
|
|
|
|
|
|
C<< "" >> to call the C<< to_string >> method and |
119
|
|
|
|
|
|
|
C<< &{} >> to call the C<< coderef >> method. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 BUGS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Please report any bugs to |
124
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=LINQ>. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SEE ALSO |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L<LINQ::FieldSet>, L<LINQ::Util>. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Toby Inkster. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
139
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
144
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
145
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |