From 0691a62ca5b43d33aa2f7b63aeb039d9155a24ed Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Fri, 2 May 2014 20:58:33 +0200 Subject: [PATCH] Call GET users/show if screen name has already been fetched Closes https://github.com/sferik/twitter/issues/561. --- lib/twitter/rest/users.rb | 4 ++-- lib/twitter/rest/utils.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/twitter/rest/users.rb b/lib/twitter/rest/users.rb index fe4ef835d..816ffd5e6 100644 --- a/lib/twitter/rest/users.rb +++ b/lib/twitter/rest/users.rb @@ -252,8 +252,8 @@ def users(*args) # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1. def user(*args) arguments = Twitter::Arguments.new(args) - if arguments.last - merge_user!(arguments.options, arguments.pop) + if arguments.last || screen_name? + merge_user!(arguments.options, arguments.pop || screen_name) perform_with_object(:get, '/1.1/users/show.json', arguments.options, Twitter::User) else verify_credentials(arguments.options) diff --git a/lib/twitter/rest/utils.rb b/lib/twitter/rest/utils.rb index b5412524b..cbfffbe16 100644 --- a/lib/twitter/rest/utils.rb +++ b/lib/twitter/rest/utils.rb @@ -118,6 +118,10 @@ def screen_name @screen_name ||= verify_credentials.screen_name end + def screen_name? + instance_variable_defined?(:@screen_name) + end + def merge_default_cursor!(options) options[:cursor] = DEFAULT_CURSOR unless options[:cursor] end