Skip to content
Snippets Groups Projects
Commit 31d6d8a8 authored by Alex Reisner's avatar Alex Reisner
Browse files

Clean up code comments.

parent ca311eab
No related branches found
No related tags found
No related merge requests found
...@@ -3,9 +3,8 @@ require 'singleton' ...@@ -3,9 +3,8 @@ require 'singleton'
module Geocoder module Geocoder
## ##
# This method can be used to change some functional aspects, like, # Provides convenient access to the Configuration singleton.
# the geocoding service provider, or the units of calculations. #
# Please see {include:Configuration}
def self.configure(&block) def self.configure(&block)
if block_given? if block_given?
module_eval(&block) module_eval(&block)
...@@ -14,14 +13,12 @@ module Geocoder ...@@ -14,14 +13,12 @@ module Geocoder
end end
end end
# This class handle the configuration process of Geocoder gem, and can be used ##
# to change some functional aspects, like, the geocoding service provider, or # This class handles geocoder Geocoder configuration
# the units of calculations. # (geocoding service provider, caching, units of measurement, etc).
# # Configuration can be done in two ways:
# == Geocoder Configuration
# #
# The configuration of Geocoder can be done in to ways: # 1) Using Geocoder.configure and passing a block:
# @example Using +Geocoder#configure+ method:
# #
# Geocoder.configure do # Geocoder.configure do
# config.timeout = 3 # geocoding service timeout (secs) # config.timeout = 3 # geocoding service timeout (secs)
...@@ -39,20 +36,17 @@ module Geocoder ...@@ -39,20 +36,17 @@ module Geocoder
# # supports SocketError and TimeoutError # # supports SocketError and TimeoutError
# config.always_raise = [] # config.always_raise = []
# #
# # Calculation options # # calculation options
# config.units = :mi # :km for kilometers or :mi for miles # config.units = :mi # :km for kilometers or :mi for miles
# config.method = :linear # :spherical or :linear # config.distances = :linear # :spherical or :linear
# end # end
# #
# @example Using +Geocoder::Configuration+ class directly, like in: # 2) Using the Geocoder::Configuration singleton directly:
# #
# Geocoder::Configuration.language = 'pt-BR' # Geocoder::Configuration.language = 'pt-BR'
# #
# == Notes # Default values are defined in Configuration#set_defaults.
# #
# All configurations are optional, the default values were shown in the first
# example (with +Geocoder#configure+).
class Configuration class Configuration
include Singleton include Singleton
...@@ -74,11 +68,10 @@ module Geocoder ...@@ -74,11 +68,10 @@ module Geocoder
attr_accessor *OPTIONS attr_accessor *OPTIONS
def initialize # :nodoc def initialize # :nodoc
set_defaults set_defaults
end end
# This method will set the configuration options to the default values
def set_defaults def set_defaults
@timeout = 3 # geocoding service timeout (secs) @timeout = 3 # geocoding service timeout (secs)
@lookup = :google # name of geocoding service (symbol) @lookup = :google # name of geocoding service (symbol)
...@@ -101,8 +94,6 @@ module Geocoder ...@@ -101,8 +94,6 @@ module Geocoder
@distances = :linear # :linear or :spherical @distances = :linear # :linear or :spherical
end end
# Delegates getters and setters for all configuration settings,
# and +set_defaults+ to the singleton instance.
instance_eval(OPTIONS.map do |option| instance_eval(OPTIONS.map do |option|
o = option.to_s o = option.to_s
<<-EOS <<-EOS
...@@ -117,7 +108,6 @@ module Geocoder ...@@ -117,7 +108,6 @@ module Geocoder
end.join("\n\n")) end.join("\n\n"))
class << self class << self
# This method will set the configuration options to the default values
def set_defaults def set_defaults
instance.set_defaults instance.set_defaults
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment