Class: Mihari::Geolocation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Mihari::Geolocation
- Defined in:
- lib/mihari/models/geolocation.rb
Class Method Summary collapse
-
.build_by_ip(ip) ⇒ Mihari::Geolocation?
Build Geolocation.
Class Method Details
.build_by_ip(ip) ⇒ Mihari::Geolocation?
Build Geolocation
17 18 19 20 21 22 23 |
# File 'lib/mihari/models/geolocation.rb', line 17 def build_by_ip(ip) res = Enrichers::IPInfo.query(ip) return nil if res&.country_code.nil? new(country: NormalizeCountry(res.country_code, to: :short), country_code: res.country_code) end |