Sha256: 74528c4b21f740616f403ff0f25ea90031b228e44b2194a937dbd825e3b45840
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
module Geokit module Cached module Geocodable def self.included(base) base.class_eval do attr_accessor :provider end end def multi_geocoder if cache_locations? Geokit::Geocoders::CachedMultiGeocoder else Geokit::Geocoders::MultiGeocoder end end def complete_address "%s, %s" % [address, country] end def geocode_address_cached @geo = multi_geocoder.geocode(complete_address) self.lat, self.lng, self.provider, self.city = @geo.lat, @geo.lng, @geo.provider, @geo.city if @geo.success end def cache_locations? self.class::CACHE_LOCATIONS end def cached_location CachedLocation.find_by_address(complete_address) || CachedLocation.new(:address => complete_address) end def cache_location! cached_location.cache!(:lat => lat, :lng => lng, :provider => provider, :city => city) if cache_locations? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
Pr0d1r2-geokit-1.3.2.10 | lib/geokit/cached/geocodable.rb |
Pr0d1r2-geokit-1.3.2.9 | lib/geokit/cached/geocodable.rb |
Pr0d1r2-geokit-1.3.2.8 | lib/geokit/cached/geocodable.rb |