From 42a1bad42e2c5232b3c1351929c1a8ca30dba999 Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Fri, 4 Mar 2011 11:12:53 -0500
Subject: [PATCH] Prevent exception when no results returned.

Geocoder.search now always returns an array. Thanks to
github.com/infinityrobot for reporting the bug.
---
 lib/geocoder/lookups/base.rb | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/geocoder/lookups/base.rb b/lib/geocoder/lookups/base.rb
index fc5fe88e..3234bbd2 100644
--- a/lib/geocoder/lookups/base.rb
+++ b/lib/geocoder/lookups/base.rb
@@ -6,15 +6,18 @@ module Geocoder
     class Base
 
       ##
-      # Takes a search string (eg: "Mississippi Coast Coliseumf, Biloxi, MS")
-      # for geocoding, or coordinates (latitude, longitude) for reverse
-      # geocoding. Returns an array of Geocoder::Result objects,
-      # or nil if not found or if network error.
+      # An array of Geocoder::Result objects.
+      #
+      # Takes a search string (eg: "Mississippi Coast Coliseumf, Biloxi, MS",
+      # "205.128.54.202") for geocoding, or coordinates (latitude, longitude)
+      # for reverse geocoding.
       #
       def search(*args)
         return [] if args[0].nil? || args[0] == ""
         if res = results(args.join(","), args.size == 2)
           res.map{ |r| result_class.new(r) }
+        else
+          []
         end
       end
 
-- 
GitLab