From 47d42273372471c9966d3756fb1a6ba677ec5281 Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Thu, 23 Apr 2009 11:15:20 -0400
Subject: [PATCH] Add 'geocoded' and 'not_geocoded' named scopes.

---
 lib/geocoder.rb | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/geocoder.rb b/lib/geocoder.rb
index 647fb044..4b795828 100644
--- a/lib/geocoder.rb
+++ b/lib/geocoder.rb
@@ -6,6 +6,22 @@
 #
 module Geocoder
   
+  ##
+  # Implementation of 'included' hook method.
+  #
+  def self.included(base)
+    base.class_eval do
+
+      # named scope: geocoded objects
+	    named_scope :geocoded,
+	      :conditions => "latitude IS NOT NULL AND longitude IS NOT NULL"
+
+      # named scope: not-geocoded objects
+	    named_scope :not_geocoded,
+	      :conditions => "latitude IS NULL OR longitude IS NULL"
+	  end
+  end
+    
   ##
   # Query Google for the coordinates of the given phrase.
   # Returns array [lat,lon] if found, nil if not found or if network error.
-- 
GitLab