Sha256: b6b4a4e1af01240a93d6e669fce5a5233019ca570e5c1652a6d0748f71034348
Contents?: true
Size: 992 Bytes
Versions: 3
Compression:
Stored size: 992 Bytes
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 = @geo.lat, @geo.lng, @geo.provider 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) if cache_locations? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
Pr0d1r2-geokit-1.3.2.6 | lib/geokit/cached/geocodable.rb |
Pr0d1r2-geokit-1.3.2.7 | lib/geokit/cached/geocodable.rb |
Pr0d1r2-geokit-1.4.1 | lib/geokit/cached/geocodable.rb |