From 484f5b922379039e1a0deb10cf8a0e31afddbce3 Mon Sep 17 00:00:00 2001 From: Thu Trang Pham <thuutrangpham@gmail.com> Date: Wed, 8 Apr 2015 18:29:12 -0400 Subject: [PATCH] Support maxminddb gem v0.1.7 --- lib/geocoder/results/geoip2.rb | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/geocoder/results/geoip2.rb b/lib/geocoder/results/geoip2.rb index 034f77f8..5cf9e9da 100644 --- a/lib/geocoder/results/geoip2.rb +++ b/lib/geocoder/results/geoip2.rb @@ -13,35 +13,35 @@ module Geocoder end def latitude - @data.fetch('location',{}).fetch('latitude',0.0) + data.fetch('location',{}).fetch('latitude',0.0) end def longitude - @data.fetch('location',{}).fetch('longitude',0.0) + data.fetch('location',{}).fetch('longitude',0.0) end def city - @data.fetch('city', {}).fetch('names', {}).fetch('en', '') + data.fetch('city', {}).fetch('names', {}).fetch('en', '') end def state - @data.fetch('subdivisions',[]).fetch(0,{}).fetch('names',{}).fetch('en','') + data.fetch('subdivisions',[]).fetch(0,{}).fetch('names',{}).fetch('en','') end def state_code - @data.fetch('subdivisions',[]).fetch(0,{}).fetch('iso_code','') + data.fetch('subdivisions',[]).fetch(0,{}).fetch('iso_code','') end def country - @data.fetch('country', {}).fetch('names',{}).fetch('en','') + data.fetch('country', {}).fetch('names',{}).fetch('en','') end def country_code - @data.fetch('country',{}).fetch('iso_code','') + data.fetch('country',{}).fetch('iso_code','') end def postal_code - @data.fetch('postal',{}).fetch('code','') + data.fetch('postal',{}).fetch('code','') end def self.response_attributes @@ -53,6 +53,12 @@ module Geocoder @data[a] end end + + private + + def data + @data.to_hash + end end end end -- GitLab