module GeoIP::Extensions::Geos

Public Class Methods

included(base) click to toggle source
# File lib/geoip/extensions/geos.rb, line 7
def self.included(base)
  base.class_eval do
    alias :look_up_without_geos :look_up
    alias :look_up :look_up_with_geos
  end
end

Public Instance Methods

look_up_with_geos(*args) click to toggle source
# File lib/geoip/extensions/geos.rb, line 14
def look_up_with_geos(*args)
  look_up_without_geos(*args).tap do |ret|
    if ret && ret[:latitude] && ret[:longitude]
      ret[:geom] = ::Geos.create_point(::Geos::CoordinateSequence.new([ ret[:longitude], ret[:latitude] ]))
    end
  end
end