From 3e72c47241522818288b44a8c847551a51fe8a26 Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Thu, 24 May 2012 00:13:49 -0400 Subject: [PATCH] Remove Geocoder.config method. This requires a parameter to be accepted by the block passed to Geocoder.configure, which means you don't need to remember that the method is called "config"--you can call it whatever you want. This behavior seems more standard for configuration blocks. --- lib/geocoder.rb | 5 ----- lib/geocoder/configuration.rb | 2 +- test/calculations_test.rb | 2 +- test/configuration_test.rb | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/geocoder.rb b/lib/geocoder.rb index 18ca7948..692551e8 100644 --- a/lib/geocoder.rb +++ b/lib/geocoder.rb @@ -70,10 +70,6 @@ module Geocoder private # ----------------------------------------------------------------- - def config # :nodoc - Configuration.instance - end - ## # Get a Lookup object (which communicates with the remote geocoding API). # Takes a search query and returns an IP or street address Lookup @@ -135,4 +131,3 @@ if defined?(Rails) require "geocoder/railtie" Geocoder::Railtie.insert end - diff --git a/lib/geocoder/configuration.rb b/lib/geocoder/configuration.rb index 17404c10..f6435283 100644 --- a/lib/geocoder/configuration.rb +++ b/lib/geocoder/configuration.rb @@ -7,7 +7,7 @@ module Geocoder # def self.configure(&block) if block_given? - module_eval(&block) + block.call(Configuration.instance) else Configuration.instance end diff --git a/test/calculations_test.rb b/test/calculations_test.rb index b1451dd4..c1be1d58 100644 --- a/test/calculations_test.rb +++ b/test/calculations_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class CalculationsTest < Test::Unit::TestCase def setup - Geocoder.configure do + Geocoder.configure do |config| config.units = :mi config.distances = :linear end diff --git a/test/configuration_test.rb b/test/configuration_test.rb index 0b038143..4137fbf4 100644 --- a/test/configuration_test.rb +++ b/test/configuration_test.rb @@ -39,7 +39,7 @@ class ConfigurationTest < Test::Unit::TestCase # --- Geocoder#configure distances configuration --- def test_geocoder_configuration # DSL - Geocoder.configure do + Geocoder.configure do |config| config.units = :mi config.distances = :linear end -- GitLab