Module: Geocoder::Orm::ActiveRecord::ClassMethods
- Defined in:
- lib/geocoder/orms/active_record.rb
Overview
Methods which will be class methods of the including class.
Instance Method Summary collapse
-
#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.
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:
-
:units
-:mi
(default) or:km
; to be used for interpreting radius as well as thedistance
attribute which is added to each found nearby object -
:bearing
-:linear
(default) or:spherical
; the method to be used for calculating the bearing (direction) between the given point and each found nearby point; set to false for no bearing calculation -
:select
- string with the SELECT SQL fragment (e.g. “id, name”) -
: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) -
:exclude
- an object to exclude (used by thenearbys
method)
71 72 73 74 75 76 77 78 |
# File 'lib/geocoder/orms/active_record.rb', line 71 def (latitude, longitude, radius = 20, = {}) radius *= Geocoder::Calculations.km_in_mi if [:units] == :km if connection.adapter_name.match /sqlite/i (latitude, longitude, radius, ) else (latitude, longitude, radius, ) end end |