From 7226966b6db9ca02dbf4fde6d4c44fc76f42b8e3 Mon Sep 17 00:00:00 2001 From: Fernando Morgenstern <contato@fernandomarcelo.com> Date: Sun, 1 Sep 2013 16:30:38 -0300 Subject: [PATCH] Move geoip gem check to the initialize function. Lookups are always loaded even when they aren't used. So the geoip gem was being checked even when user wouldn't like to use the maxmind_local lookup. --- lib/geocoder/lookups/maxmind_local.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/geocoder/lookups/maxmind_local.rb b/lib/geocoder/lookups/maxmind_local.rb index fb6ac7f5..62ed2d64 100644 --- a/lib/geocoder/lookups/maxmind_local.rb +++ b/lib/geocoder/lookups/maxmind_local.rb @@ -1,15 +1,19 @@ require 'geocoder/lookups/base' require 'geocoder/results/maxmind_local' -begin - require 'geoip' -rescue LoadError => e - raise 'Could not load geoip dependency. To use MaxMind Local lookup you must add geoip gem to your Gemfile or have it installed in your system.' -end - module Geocoder::Lookup class MaxmindLocal < Base + def initialize + begin + require 'geoip' + rescue LoadError => e + raise 'Could not load geoip dependency. To use MaxMind Local lookup you must add geoip gem to your Gemfile or have it installed in your system.' + end + + super + end + def name "MaxMind Local" end -- GitLab