Sha256: 413d36cd0e05867fa43ebbcd03f11212eedcc941118dc0f6a5e2a47a778dba14
Contents?: true
Size: 1.77 KB
Versions: 5
Compression:
Stored size: 1.77 KB
Contents
require 'geocoder' module Geocoder ## # Methods for invoking Geocoder in a model. # module Model module MongoBase ## # Set attribute names and include the Geocoder module. # def geocoded_by(address_attr, options = {}, &block) geocoder_init( :geocode => true, :user_address => address_attr, :coordinates => options[:coordinates] || :coordinates, :geocode_block => block, :units => options[:units], :method => options[:method], :skip_index => options[:skip_index] || false, :lookup => options[:lookup] ) end ## # Set attribute names and include the Geocoder module. # def reverse_geocoded_by(coordinates_attr, options = {}, &block) geocoder_init( :reverse_geocode => true, :fetched_address => options[:address] || :address, :coordinates => coordinates_attr, :reverse_block => block, :units => options[:units], :method => options[:method], :skip_index => options[:skip_index] || false, :lookup => options[:lookup] ) end private # ---------------------------------------------------------------- def geocoder_init(options) unless geocoder_initialized? @geocoder_options = { } require "geocoder/stores/#{geocoder_file_name}" include Geocoder::Store.const_get(geocoder_module_name) end @geocoder_options.merge! options end def geocoder_initialized? included_modules.include? Geocoder::Store.const_get(geocoder_module_name) rescue NameError false end end end end
Version data entries
5 entries across 5 versions & 1 rubygems