module TwitterWithAutoPagination::REST::Users

Constants

MAX_USERS_PER_REQUEST

Public Instance Methods

blocked_ids(*args) click to toggle source
# File lib/twitter_with_auto_pagination/rest/users.rb, line 34
def blocked_ids(*args)
  twitter.send(__method__, *args).attrs[:ids]
end
user(*args) click to toggle source
# File lib/twitter_with_auto_pagination/rest/users.rb, line 17
def user(*args)
  twitter.send(__method__, *args).to_hash
end
user?(*args) click to toggle source
# File lib/twitter_with_auto_pagination/rest/users.rb, line 13
def user?(*args)
  twitter.send(__method__, *args)
end
users(values, options = {}) click to toggle source

client.users -> cached users(internal call) -> cached super -> not cached

# File lib/twitter_with_auto_pagination/rest/users.rb, line 26
def users(values, options = {})
  if values.size <= MAX_USERS_PER_REQUEST
    return twitter.send(__method__, *values, options).map(&:to_hash)
  end

  users_internal(values, options)
end
verify_credentials(options = {}) click to toggle source
# File lib/twitter_with_auto_pagination/rest/users.rb, line 9
def verify_credentials(options = {})
  twitter.send(__method__, {skip_status: true}.merge(options)).to_hash
end

Private Instance Methods

users_internal(values, options = {}) click to toggle source
# File lib/twitter_with_auto_pagination/rest/users.rb, line 40
def users_internal(values, options = {})
  options = options.merge(super_operation: :users)
  threads = options.delete(:threads) || 5

  if threads > 1
    parallel(in_threads: threads) do |batch|
      values.each_slice(MAX_USERS_PER_REQUEST) { |targets| batch.users(targets, options) }
    end.flatten
  else
    values.each_slice(MAX_USERS_PER_REQUEST).map { |targets| users(targets, options) }.flatten
  end
end