Permalink
Browse files

Change lookup method: takes query instead of bool.

Figures out whether query is an IP address so you don't have to.
  • Loading branch information...
1 parent 6581c60 commit ce6b4b0ad9eba3780f65a02784d3a4be3c11b8a5 @alexreisner alexreisner committed Apr 22, 2011
Showing with 5 additions and 4 deletions.
  1. +5 −4 lib/geocoder.rb
View
@@ -20,7 +20,7 @@ def search(query, *args)
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 @@ class ConfigurationError < Error; end
##
# 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)

0 comments on commit ce6b4b0

Please sign in to comment.