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

Cache request location lookup result.

parent dd61291a
Branches
Tags
No related merge requests found
......@@ -5,13 +5,16 @@ module Geocoder
module Request
def location
unless defined?(@location)
if ip.nil? or ip == "0.0.0.0" or ip.match /^127/ # don't look up loopback
# but return a Geocoder::Result for consistency
Geocoder::Result::Freegeoip.new("ip" => ip)
@location = Geocoder::Result::Freegeoip.new("ip" => ip)
else
Geocoder.search(ip).first
@location = Geocoder.search(ip).first
end
end
@location
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment