class Jumble::REST::Client

Private Instance Methods

config() click to toggle source
# File lib/jumble/rest/client.rb, line 17
def config
  @config ||= begin
    file = ::File.open(::Rails.root.join('config', 'jumble.yml'))
    ::YAML.load(file)
  end
end
connection() click to toggle source
# File lib/jumble/rest/client.rb, line 9
def connection
  @connection ||= connections.sample
end
connections() click to toggle source
# File lib/jumble/rest/client.rb, line 13
def connections
  @connections ||= config.map { |payload| Connection.new(payload) }
end
method_missing(*args, &block) click to toggle source
# File lib/jumble/rest/client.rb, line 24
def method_missing(*args, &block)
  connection.client.send(*args, &block)
rescue ::Twitter::Error::TooManyRequests => e
  connection.reset(e.rate_limit.reset_at)

  if connections.any?(&:alive?)
    @connection = next_connection
    retry
  else
    raise TooManyRequests.new(next_connection.reset_at)
  end
end
next_connection() click to toggle source
# File lib/jumble/rest/client.rb, line 37
def next_connection
  connections.sort.first
end