Pr0d1r2-geokit 1.3.2.5 → 1.3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/geokit.rb +1 -1
- data/lib/geokit/cached/geocodable.rb +12 -4
- data/lib/geokit/cached/model.rb +6 -0
- metadata +1 -1
data/lib/geokit.rb
CHANGED
@@ -16,19 +16,27 @@ module Geokit
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def complete_address
|
20
|
+
"%s, %s" % [address, country]
|
21
|
+
end
|
22
|
+
|
19
23
|
def geocode_address_cached
|
20
24
|
@geo = multi_geocoder.geocode(complete_address)
|
21
25
|
self.lat, self.lng, self.provider = @geo.lat, @geo.lng, @geo.provider if @geo.success
|
22
26
|
end
|
23
27
|
|
24
|
-
def cache_location!
|
25
|
-
cached_location.cache!(:lat => lat, :lng => lng, :provider => provider) if cache_locations?
|
26
|
-
end
|
27
|
-
|
28
28
|
def cache_locations?
|
29
29
|
self.class::CACHE_LOCATIONS
|
30
30
|
end
|
31
31
|
|
32
|
+
def cached_location
|
33
|
+
CachedLocation.find_by_address(complete_address) || CachedLocation.new(:address => complete_address)
|
34
|
+
end
|
35
|
+
|
36
|
+
def cache_location!
|
37
|
+
cached_location.cache!(:lat => lat, :lng => lng, :provider => provider) if cache_locations?
|
38
|
+
end
|
39
|
+
|
32
40
|
end
|
33
41
|
end
|
34
42
|
end
|
data/lib/geokit/cached/model.rb
CHANGED