root/WWW-OpenSearch/trunk/lib/WWW/OpenSearch/Agent.pm

Revision 2407 (checked in by bricas, 13 years ago)

perltidy

Line 
1 package WWW::OpenSearch::Agent;
2
3 use strict;
4 use warnings;
5
6 use base qw( LWP::UserAgent );
7
8 use WWW::OpenSearch;
9 use WWW::OpenSearch::Response;
10
11 =head1 NAME
12
13 WWW::OpenSearch::Agent - An agent for doing OpenSearch requests
14
15 =head1 SYNOPSIS
16
17 =head1 DESCRIPTION
18
19 =head1 CONSTRUCTOR
20
21 =head2 new( [%options] )
22
23 =head1 METHODS
24
25 =head2 request( $request | $url, \%params )
26
27 =head2 search( )
28
29 An alias for request()
30
31 =head1 AUTHOR
32
33 =over 4
34
35 =item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>
36
37 =back
38
39 =head1 COPYRIGHT AND LICENSE
40
41 Copyright 2007 by Tatsuhiko Miyagawa and Brian Cassidy
42
43 This library is free software; you can redistribute it and/or modify
44 it under the same terms as Perl itself.
45
46 =cut
47
48 sub new {
49     my ( $class, @rest ) = @_;
50     return $class->SUPER::new(
51         agent => join( '/', __PACKAGE__, $WWW::OpenSearch::VERSION ),
52         @rest,
53     );
54 }
55
56 *search = \&request;
57
58 sub request {
59     my $self     = shift;
60     my $request  = shift;
61     my $response = $self->SUPER::request( $request, @_ );
62
63     # allow regular HTTP::Requests to flow through
64     return $response unless $request->isa( 'WWW::OpenSearch::Request' );
65     return WWW::OpenSearch::Response->new( $response );
66 }
67
68 1;
Note: See TracBrowser for help on using the browser.