/usr/share/perl5/WebService/Solr/Field.pm is in libwebservice-solr-perl 0.42-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | package WebService::Solr::Field;
use XML::Easy::Element;
use XML::Easy::Content;
use XML::Easy::Text ();
sub new {
my ( $class, $name, $value, $opts ) = @_;
$opts ||= {};
die "name required" unless defined $name;
die "value required" unless defined $value;
my $self = {
name => $name,
value => $value,
%{ $opts },
};
return bless $self, $class;
}
sub name {
my $self = shift;
$self->{ name } = $_[ 0 ] if @_;
return $self->{ name };
}
sub value {
my $self = shift;
$self->{ value } = $_[ 0 ] if @_;
return $self->{ value };
}
sub boost {
my $self = shift;
$self->{ boost } = $_[ 0 ] if @_;
return $self->{ boost };
}
sub to_element {
my $self = shift;
my %attr = ( $self->boost ? ( boost => $self->boost ) : () );
return XML::Easy::Element->new(
'field',
{ name => $self->name, %attr },
XML::Easy::Content->new( [ $self->value ] ),
);
}
sub to_xml {
my $self = shift;
return XML::Easy::Text::xml10_write_element( $self->to_element );
}
1;
__END__
=head1 NAME
WebService::Solr::Field - A field object
=head1 SYNOPSIS
my $field = WebService::Solr::Field->new( foo => 'bar' );
=head1 DESCRIPTION
This class represents a field from a document, which is basically a
name-value pair.
=head1 ACCESSORS
=over 4
=item * name - the field's name
=item * value - the field's value
=item * boost - a floating-point boost value
=back
=head1 METHODS
=head2 new( $name => $value, \%options )
Creates a new field object. Currently, the only option available is a
"boost" value.
=head2 BUILDARGS( @args )
A Moo override to allow our custom constructor.
=head2 to_element( )
Serializes the object to an XML::Easy::Element object.
=head2 to_xml( )
Serializes the object to xml.
=head1 AUTHORS
Brian Cassidy E<lt>bricas@cpan.orgE<gt>
Kirk Beers
=head1 COPYRIGHT AND LICENSE
Copyright 2008-2016 National Adult Literacy Database
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
|