Sha256: c5c0fc6fdf1f06f48c66e5aca6433baf68794e5a79e7b288d97bac7ae1f7b89d
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 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, true 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
Pr0d1r2-geokit-1.3.2.2 | lib/geokit/cached/model.rb |
Pr0d1r2-geokit-1.3.2.3 | lib/geokit/cached/model.rb |
Pr0d1r2-geokit-1.3.2.4 | lib/geokit/cached/model.rb |