Class: Geocoder::Configuration
- Inherits:
-
Object
- Object
- Geocoder::Configuration
- Includes:
- Singleton
- Defined in:
- lib/geocoder/configuration.rb
Constant Summary collapse
- OPTIONS =
[ :timeout, :lookup, :ip_lookup, :language, :host, :http_headers, :use_https, :http_proxy, :https_proxy, :api_key, :cache, :cache_prefix, :always_raise, :units, :distances, :basic_auth, :logger, :kernel_logger_level, :cache_options ]
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #configure(options) ⇒ Object
-
#initialize ⇒ Configuration
constructor
:nodoc.
- #set_defaults ⇒ Object
Constructor Details
#initialize ⇒ Configuration
:nodoc
94 95 96 97 |
# File 'lib/geocoder/configuration.rb', line 94 def initialize # :nodoc @data = Geocoder::ConfigurationHash.new set_defaults end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
75 76 77 |
# File 'lib/geocoder/configuration.rb', line 75 def data @data end |
Class Method Details
.set_defaults ⇒ Object
77 78 79 |
# File 'lib/geocoder/configuration.rb', line 77 def self.set_defaults instance.set_defaults end |
Instance Method Details
#configure(options) ⇒ Object
90 91 92 |
# File 'lib/geocoder/configuration.rb', line 90 def configure() Util.recursive_hash_merge(@data, ) end |
#set_defaults ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/geocoder/configuration.rb', line 99 def set_defaults # geocoding options @data[:timeout] = 3 # geocoding service timeout (secs) @data[:lookup] = :nominatim # name of street address geocoding service (symbol) @data[:ip_lookup] = :ipinfo_io # name of IP address geocoding service (symbol) @data[:language] = :en # ISO-639 language code @data[:http_headers] = {} # HTTP headers for lookup @data[:use_https] = false # use HTTPS for lookup requests? (if supported) @data[:http_proxy] = nil # HTTP proxy server (user:pass@host:port) @data[:https_proxy] = nil # HTTPS proxy server (user:pass@host:port) @data[:api_key] = nil # API key for geocoding service @data[:cache] = nil # cache object (must respond to #[], #[]=, and optionally #keys) @data[:cache_prefix] = nil # - DEPRECATED - prefix (string) to use for all cache keys @data[:basic_auth] = {} # user and password for basic auth ({:user => "user", :password => "password"}) @data[:logger] = :kernel # :kernel or Logger instance @data[:kernel_logger_level] = ::Logger::WARN # log level, if kernel logger is used # exceptions that should not be rescued by default # (if you want to implement custom error handling); # supports SocketError and Timeout::Error @data[:always_raise] = [] # calculation options @data[:units] = :mi # :mi or :km @data[:distances] = :linear # :linear or :spherical # explicit cache service options @data[:cache_options] ||= {} @data[:cache_options][:prefix] = "geocoder:" end |