Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

AutoCursor should not modify behavior when user passes a cursor

  • Loading branch information...
commit 24c92a3c0d38b8c9ec364d457c59a29a2ab2b3c9 1 parent 2622140
@semifor authored
Showing with 11 additions and 9 deletions.
  1. +11 −9 lib/Net/Twitter/Role/AutoCursor.pm
View
20 lib/Net/Twitter/Role/AutoCursor.pm
@@ -15,7 +15,11 @@ role {
my $orig = shift;
my $self = shift;
- my $args = ref $_[-1] eq 'HASH' ? pop : {};
+ my $args = ref $_[-1] eq ref {} ? pop : {};
+
+ # no change in behavior if the user passed a cursor
+ return $self->$orig(@_, $args) if exists $args->{cursor};
+
$args->{id} = shift if @_;
$args->{cursor} = -1 if !exists $args->{cursor} && $p->force_cursor;
@@ -25,16 +29,14 @@ role {
my $calls = 0;
my $results;
if ( !exists $args->{cursor} ) {
+ # try the old style, non-cursored call
my $r = $orig->($self, $args);
+ return $r if ref $r eq ref [];
+
++$calls;
- if ( ref $r eq 'HASH' ) {
- # If Twitter forces a cursored call, we'll get a HASH instead of an ARRAY
- $results = $r->{$p->array_accessor};
- $args->{cursor} = $r->{next_cursor};
- }
- else {
- $results = $r;
- }
+ # If Twitter forces a cursored call, we'll get a HASH instead of an ARRAY
+ $results = $r->{$p->array_accessor};
+ $args->{cursor} = $r->{next_cursor};
}
while ( $args->{cursor} && $calls++ < $max_calls ) {
Please sign in to comment.
Something went wrong with that request. Please try again.