Sha256: 4f5e11f8cad23bc37e8f6cd669eedf2cf3137e0a79396d1e97d4f44f1b88d837
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module Geokit module Cached module Model def cache!(attributes) self.attributes = attributes save if new_record? || changed? end def update! if !by_google? && geo.success self.lat, self.lng, self.provider = geo.lat, geo.lng, geo.provider save if changed? end end def update_and_return! update! geoloc end def geo @geo ||= Geokit::Geocoders::MultiGeocoder.geocode(address) end def fake_geoloc geoloc = Geokit::GeoLoc.new geoloc.lat, geoloc.lng, geoloc.provider, geoloc.success = lat, lng, provider, success? geoloc end def successful_geoloc geo if geocoding_occured? && geo.success end def geoloc successful_geoloc || fake_geoloc end def by_google? provider == 'google' end def changed_to_google? by_google? && provider_changed? end def changed? lat_changed? || lng_changed? || changed_to_google? end def geocoding_occured? !@geo.nil? end def success? !!(lat and lng) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Pr0d1r2-geokit-1.3.2.5 | lib/geokit/cached/model.rb |