10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/has_distance/distance.rb', line 10
def has_distance(field_name=:distance, options={}, &block)
cattr_accessor :distance_config
self.distance_config = Struct.new(:column_name,
:lat_name,
:lng_name,
:units,
:distance,
:limit
).new(
field_name,
options[:latitude] || 'latitude',
options[:longitude] || 'longitude',
options[:units] || :miles,
options[:distance] || 20,
options[:limit] || 12
)
if block_given?
block.call(self.distance_config)
end
end
|