Permalink
Browse files

Small refactoring in request sending

  • Loading branch information...
1 parent 78d9cfa commit e61822cac95a650c3d242eabafc07f91c25e6807 Jeroen Jacobs committed May 20, 2011
Showing with 1 addition and 5 deletions.
  1. +1 −5 lib/geo_ip.rb
View
@@ -43,15 +43,11 @@ def self.geolocation(ip, options={})
raise "Invalid precision" unless [:country, :city].include?(@precision)
raise "Invalid timezone" unless [true, false].include?(@timezone)
url = "#{SERVICE_URL}#{@country ? COUNTRY_API : CITY_API}?key=#{self.api_key}&ip=#{ip}&output=json&timezone=#{@timezone}"
- reply = JSON.parse send_request(url)
+ reply = JSON.parse RestClient::Request.execute(:method => :get, :url => url, :timeout => self.timeout)
location = convert_keys reply
end
private
- def send_request url
- RestClient::Request.execute(:method => :get, :url => url, :timeout => self.timeout)
- end
-
def self.convert_keys(hash)
location = {}
location[:ip] = hash["Ip"]

0 comments on commit e61822c

Please sign in to comment.