| 1 | package Net::StackExchange::Route; | ||
| 2 | 4 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 4 | $Net::StackExchange::Route::VERSION = '0.102740'; | |
| 4 | } | ||
| 5 | |||
| 6 | # ABSTRACT: Builds appropriate request object | ||
| 7 | |||
| 8 | 4 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 4 | has '_route' => ( | |
| 11 | is => 'ro', | ||
| 12 | isa => 'Str', | ||
| 13 | ); | ||
| 14 | |||
| 15 | 4 | has '_NSE' => ( | |
| 16 | is => 'ro', | ||
| 17 | isa => 'Net::StackExchange', | ||
| 18 | required => 1, | ||
| 19 | ); | ||
| 20 | |||
| 21 | 1 | ▶ | sub prepare_request { |
|
Subroutine
prepare_request: called CC=1 SCAR=0.0
Pod
documented
| |||
| 22 | 1 | my ( $self, $arg ) = @_; | |
| 23 | |||
| 24 | 1 | $arg->{'_NSE'} = $self->_NSE(); | |
| 25 | 1 | my $route = $self->_route(); | |
| 26 | 1 | return "Net::StackExchange::${route}::Request"->new($arg); | |
| 27 | } | ||
| 28 | |||
| 29 | 4 | __PACKAGE__->meta()->make_immutable(); | |
| 30 | |||
| 31 | 4 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 32 | |||
| 33 | 4 | 1; | |
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | =pod | ||
| 38 | |||
| 39 | =head1 NAME | ||
| 40 | |||
| 41 | Net::StackExchange::Route - Builds appropriate request object | ||
| 42 | |||
| 43 | =head1 VERSION | ||
| 44 | |||
| 45 | version 0.102740 | ||
| 46 | |||
| 47 | =head1 SYNOPSIS | ||
| 48 | |||
| 49 | use Net::StackExchange; | ||
| 50 | |||
| 51 | my $se = Net::StackExchange->new( { | ||
| 52 | 'network' => 'stackoverflow.com', | ||
| 53 | 'version' => '1.0', | ||
| 54 | } ); | ||
| 55 | |||
| 56 | my $answers_route = $se->route('answers'); | ||
| 57 | my $answers_request = $answers_route->prepare_request( { 'id' => 1036353 } ); | ||
| 58 | |||
| 59 | =head1 METHODS | ||
| 60 | |||
| 61 | =head2 C<prepare_request> | ||
| 62 | |||
| 63 | Returns respective request object based on the route with which this object has | ||
| 64 | been created. The request object for the particular route will be constructed | ||
| 65 | using the hash reference that is passed to C<prepare_request>. | ||
| 66 | |||
| 67 | =head1 AUTHOR | ||
| 68 | |||
| 69 | Alan Haggai Alavi <alanhaggai@alanhaggai.org> | ||
| 70 | |||
| 71 | =head1 COPYRIGHT AND LICENSE | ||
| 72 | |||
| 73 | This software is copyright (c) 2010 by Alan Haggai Alavi. | ||
| 74 | |||
| 75 | This is free software; you can redistribute it and/or modify it under | ||
| 76 | the same terms as the Perl 5 programming language system itself. | ||
| 77 | |||
| 78 | =cut | ||
| 79 | |||
| 80 | |||
| 81 | __END__ | ||