Module: Geocoder::ClassMethods

Defined in:
lib/geocoder.rb

Overview

Methods which will be class methods of the including class.

Instance Method Summary collapse

Instance Method Details

#near_scope_options(latitude, longitude, radius = 20, options = {}) ⇒ Object

Get options hash suitable for passing to ActiveRecord.find to get records within a radius (in miles) of the given point. Options hash may include:

order

column(s) for ORDER BY SQL clause

limit

number of records to return (for LIMIT SQL clause)

offset

number of records to skip (for OFFSET SQL clause)

select

string with the SELECT SQL fragment (e.g. “id, name”)



57
58
59
60
61
62
63
# File 'lib/geocoder.rb', line 57

def near_scope_options(latitude, longitude, radius = 20, options = {})
  if ActiveRecord::Base.connection.adapter_name == "SQLite"
    approx_near_scope_options(latitude, longitude, radius, options)
  else
    full_near_scope_options(latitude, longitude, radius, options)
  end
end