From 0960e93bc437ca19386657f66700de508a369bda Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Thu, 24 Mar 2011 15:29:58 -0400 Subject: [PATCH] Change second nearbys method to options hash. Response to Issue #27, posted by github.com/avioing. --- lib/geocoder/orms/base.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/geocoder/orms/base.rb b/lib/geocoder/orms/base.rb index 90666ae6..666cfbc9 100644 --- a/lib/geocoder/orms/base.rb +++ b/lib/geocoder/orms/base.rb @@ -30,12 +30,16 @@ module Geocoder alias_method :distance_from, :distance_to ## - # Get nearby geocoded objects. Takes a radius (integer) and a symbol - # representing the units of the ratius (:mi or :km; default is :mi). + # Get nearby geocoded objects. + # Takes the same options hash as the near class method (scope). # - def nearbys(radius = 20, units = :mi) + def nearbys(radius = 20, options = {}) return [] unless geocoded? - options = {:exclude => self, :units => units} + if options.is_a?(Symbol) + options = {:units => options} + warn "DEPRECATION WARNING: The units argument to the nearbys method has been replaced with an options hash (same options hash as the near scope). You should instead call: obj.nearbys(#{radius}, :units => #{options[:units]}). The old syntax will not be supported in Geocoder v1.0." + end + options.merge!(:exclude => self) self.class.near(to_coordinates, radius, options) end -- GitLab