line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
83
|
use 5.006; |
|
4
|
|
|
|
|
14
|
|
2
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
104
|
|
3
|
4
|
|
|
4
|
|
25
|
use warnings; |
|
4
|
|
|
|
|
28
|
|
|
4
|
|
|
|
|
280
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
7
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Class::Tiny qw( index name value params ); |
10
|
4
|
|
|
4
|
|
25
|
|
|
4
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
25
|
|
11
|
|
|
|
|
|
|
my ( $self ) = ( shift ); |
12
|
|
|
|
|
|
|
|
13
|
83
|
|
|
83
|
1
|
3084
|
if ( not $self->{params} ) { |
14
|
|
|
|
|
|
|
$self->{params} = {}; |
15
|
83
|
100
|
|
|
|
206
|
} |
16
|
7
|
|
|
|
|
11
|
|
17
|
|
|
|
|
|
|
if ( not defined $self->{name} ) { |
18
|
|
|
|
|
|
|
if ( defined $self->{params}{as} ) { |
19
|
83
|
100
|
|
|
|
187
|
$self->{name} = $self->{params}{as}; |
20
|
79
|
100
|
100
|
|
|
491
|
} |
|
|
100
|
|
|
|
|
|
21
|
11
|
|
|
|
|
26
|
elsif ( !ref $self->{value} and $self->{value} =~ /\A[^\W0-9]\w*\z/ ) { |
22
|
|
|
|
|
|
|
$self->{name} = $self->{value}; |
23
|
|
|
|
|
|
|
} |
24
|
66
|
|
|
|
|
189
|
else { |
25
|
|
|
|
|
|
|
$self->{name} = sprintf( '_%d', $self->{index} ); |
26
|
|
|
|
|
|
|
} |
27
|
2
|
|
|
|
|
9
|
} #/ if ( not defined $self...) |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} #/ sub BUILD |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my ( $self ) = @_; |
32
|
|
|
|
|
|
|
$self->{getter} ||= $self->_build_getter; |
33
|
|
|
|
|
|
|
} |
34
|
81
|
|
|
81
|
1
|
929
|
|
35
|
81
|
|
100
|
|
|
249
|
my ( $self ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $attr = $self->value; |
38
|
|
|
|
|
|
|
|
39
|
68
|
|
|
68
|
|
106
|
if ( ref( $attr ) eq 'CODE' ) { |
40
|
|
|
|
|
|
|
return $attr; |
41
|
68
|
|
|
|
|
1091
|
} |
42
|
|
|
|
|
|
|
|
43
|
68
|
100
|
|
|
|
361
|
require Scalar::Util; |
44
|
4
|
|
|
|
|
18
|
|
45
|
|
|
|
|
|
|
return sub { |
46
|
|
|
|
|
|
|
my $blessed = Scalar::Util::blessed( $_ ); |
47
|
64
|
|
|
|
|
242
|
if ( ( $blessed || '' ) =~ /\AObject::Adhoc::__ANON__::/ ) { |
48
|
|
|
|
|
|
|
$blessed = undef; |
49
|
|
|
|
|
|
|
} |
50
|
153
|
|
|
153
|
|
392
|
scalar( $blessed ? $_->$attr : $_->{$attr} ); |
51
|
153
|
100
|
100
|
|
|
531
|
}; |
52
|
96
|
|
|
|
|
206
|
} #/ sub _build_getter |
53
|
|
|
|
|
|
|
|
54
|
153
|
100
|
|
|
|
1315
|
1; |
55
|
64
|
|
|
|
|
400
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=encoding utf-8 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
LINQ::Field - represents a single field in a LINQ::FieldSet |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 DESCRIPTION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
See L<LINQ::FieldSet> for details. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This is used internally by LINQ and you probably don't need to know about it |
70
|
|
|
|
|
|
|
unless you're writing very specific extensions for LINQ. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item C<< new( ARGSHASH ) >> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=begin trustme |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item BUILD |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=end trustme |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 METHODS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item C<index> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The order of a field within a fieldset. Starts at zero. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item C<name> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The name of a field. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item C<value> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The hashref key or method name used to find the value for the field from |
101
|
|
|
|
|
|
|
a hashref or object; or a coderef which will get the value from C<< $_ >>. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item C<params> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Additional metadata for the field. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item C<getter> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
A coderef which will get the value of a field from C<< $_ >>. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 BUGS |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Please report any bugs to |
116
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=LINQ>. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SEE ALSO |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L<LINQ::FieldSet>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Toby Inkster. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
131
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
136
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
137
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |