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

Add Rack::Request#location method.

parent 26643bee
No related branches found
No related tags found
No related merge requests found
require "geocoder/configuration"
require "geocoder/calculations"
require "geocoder/railtie"
require "geocoder/request"
module Geocoder
extend self
......
require 'geocoder'
require 'geocoder/results/freegeoip'
module Geocoder
module Request
def 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)
else
Geocoder.search(ip).first
end
end
end
end
if defined?(Rack) and defined?(Rack::Request)
Rack::Request.send :include, Geocoder::Request
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