line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
34
|
use 5.006; |
|
2
|
|
|
|
|
6
|
|
2
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
44
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
133
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
7
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Class::Tiny; |
10
|
2
|
|
|
2
|
|
13
|
use parent qw( LINQ::FieldSet ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
11
|
2
|
|
|
2
|
|
136
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
12
|
|
|
|
|
|
|
use overload ( |
13
|
|
|
|
|
|
|
'fallback' => !!1, |
14
|
|
|
|
|
|
|
q[bool] => sub { !! 1 }, |
15
|
2
|
|
|
2
|
|
6
|
q[""] => 'to_string', |
16
|
2
|
|
|
|
|
24
|
q[&{}] => 'coderef', |
17
|
|
|
|
|
|
|
); |
18
|
2
|
|
|
2
|
|
176
|
|
|
2
|
|
|
|
|
3
|
|
19
|
|
|
|
|
|
|
my $class = shift; |
20
|
|
|
|
|
|
|
my $field = shift; |
21
|
7
|
|
|
7
|
1
|
13
|
my $self = $class->SUPER::new( $field ); |
22
|
7
|
|
|
|
|
10
|
|
23
|
7
|
|
|
|
|
31
|
if ( wantarray ) { |
24
|
|
|
|
|
|
|
return ( $self, @_ ); |
25
|
7
|
50
|
|
|
|
122
|
} |
26
|
7
|
|
|
|
|
39
|
|
27
|
|
|
|
|
|
|
if ( @_ ) { |
28
|
|
|
|
|
|
|
LINQ::Util::Internal::throw( |
29
|
0
|
0
|
|
|
|
0
|
'CallerError', |
30
|
0
|
|
|
|
|
0
|
'message' => 'Unexpected extra parameters; single field name expected', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
0
|
|
37
|
|
|
|
|
|
|
my ( $self ) = ( shift ); |
38
|
|
|
|
|
|
|
$self->{coderef} ||= $self->_build_coderef; |
39
|
|
|
|
|
|
|
} |
40
|
37
|
|
|
37
|
1
|
54
|
|
41
|
37
|
|
66
|
|
|
117
|
my ( $self ) = ( shift ); |
42
|
|
|
|
|
|
|
my ( $field ) = @{ $self->fields }; |
43
|
|
|
|
|
|
|
return $field->getter; |
44
|
|
|
|
|
|
|
} |
45
|
7
|
|
|
7
|
|
15
|
|
46
|
7
|
|
|
|
|
11
|
my ( $self ) = ( shift ); |
|
7
|
|
|
|
|
179
|
|
47
|
7
|
|
|
|
|
55
|
sprintf 'field(%s)', join q[, ], map $_->name, @{ $self->fields }; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
0
|
|
|
0
|
1
|
|
|
52
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=encoding utf-8 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
LINQ::FieldSet::Single - similar to LINQ::FieldSet::Selection, but only selects one field |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
LINQ::FieldSet::Single is a subclass of L<LINQ::FieldSet>. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This is used internally by LINQ and you probably don't need to know about it |
66
|
|
|
|
|
|
|
unless you're writing very specific extensions for LINQ. The end user |
67
|
|
|
|
|
|
|
interface is the C<field> function in L<LINQ::Util>. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item C<< new( NAME, EXTRAARGS ) >> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Constructs a fieldset like: |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
'LINQ::FieldSet::Single'->new( 'name', @stuff ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
If called in scalar context, and C<< @stuff >> isn't the empty list, then |
80
|
|
|
|
|
|
|
will throw an exception. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
If called in list context, will return the newly constructed object followed |
83
|
|
|
|
|
|
|
by unadulterated C<< @stuff >>. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 METHODS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item C<coderef> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Gets a coderef for this assertion; the coderef operates on C<< $_ >>. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item C<to_string> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Basic string representation of the fieldset. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 OVERLOADING |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This class overloads |
104
|
|
|
|
|
|
|
C<< "" >> to call the C<< to_string >> method and |
105
|
|
|
|
|
|
|
C<< &{} >> to call the C<< coderef >> method. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 BUGS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Please report any bugs to |
110
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=LINQ>. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SEE ALSO |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<LINQ::FieldSet>, L<LINQ::Util>. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Toby Inkster. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
125
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
130
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
131
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |