Sha256: 1d47e2717cb345e477355675349d70cf3c1e76d5bcccd9da0b0f7b6dc051bf9b
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 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 ) 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 ) end private # ---------------------------------------------------------------- def geocoder_init(options) unless geocoder_initialized? @geocoder_options = {} require "geocoder/stores/#{geocoder_file_name}" include eval("Geocoder::Store::" + geocoder_module_name) end @geocoder_options.merge! options end def geocoder_initialized? begin included_modules.include? eval("Geocoder::Store::" + geocoder_module_name) rescue NameError false end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geocoder-1.0.2 | lib/geocoder/models/mongo_base.rb |