Skip to content

Commit

Permalink
Added method usage to the examples on SYNOPSIS
Browse files Browse the repository at this point in the history
  • Loading branch information
Getty committed Oct 13, 2012
1 parent 4e86c5f commit 52130a3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/WWW/Chain.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ our $VERSION ||= '0.000';

=head1 SYNOPSIS
# Coderef usage
my $chain = WWW::Chain->new(HTTP::Request->new( GET => 'http://localhost/' ), sub {
my ( $chain, $response ) = @_;
$chain->stash->{first_request} = 'done';
Expand All @@ -18,6 +20,26 @@ our $VERSION ||= '0.000';
};
});
# Method usage (can be mixed with Coderef)
{
package TestWWWChainMethods;
use Moo;
extends 'WWW::Chain';
sub first_request {
$_[0]->stash->{a} = 1;
return HTTP::Request->new( GET => 'http://duckduckgo.com/' ), "second_request";
}
sub second_request {
$_[0]->stash->{b} = 2;
return;
}
}
my $chain = TestWWWChainMethods->new(HTTP::Request->new( GET => 'http://duckduckgo.com/' ), 'first_request');
# Blocking usage:
my $ua = WWW::Chain::UA::LWP->new;
Expand Down

0 comments on commit 52130a3

Please sign in to comment.