From ce6b4b0ad9eba3780f65a02784d3a4be3c11b8a5 Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Fri, 22 Apr 2011 16:39:18 -0400
Subject: [PATCH] Change lookup method: takes query instead of bool.

Figures out whether query is an IP address so you don't have to.
---
 lib/geocoder.rb | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/geocoder.rb b/lib/geocoder.rb
index 2ef99625..daf717d5 100644
--- a/lib/geocoder.rb
+++ b/lib/geocoder.rb
@@ -20,7 +20,7 @@ module Geocoder
     if blank_query?(query)
       results = []
     else
-      results = lookup(ip_address?(query)).search(query)
+      results = lookup(query).search(query)
     end
     results.instance_eval do
       def warn_search_deprecation(attr)
@@ -107,10 +107,11 @@ module Geocoder
 
   ##
   # Get a Lookup object (which communicates with the remote geocoding API).
-  # Returns an IP address lookup if +ip+ parameter true.
+  # Takes a search query and returns an IP or street address Lookup
+  # depending on the query contents.
   #
-  def lookup(ip = false)
-    if ip
+  def lookup(query)
+    if ip_address?(query)
       get_lookup(ip_lookups.first)
     else
       get_lookup(Configuration.lookup || street_lookups.first)
-- 
GitLab