lib/mihari/models/geolocation.rb in mihari-5.6.2 vs lib/mihari/models/geolocation.rb in mihari-5.7.0
- old
+ new
@@ -2,10 +2,13 @@
require "normalize_country"
module Mihari
module Models
+ #
+ # Geolocation model
+ #
class Geolocation < ActiveRecord::Base
belongs_to :artifact
class << self
include Dry::Monads[:result]
@@ -17,10 +20,10 @@
# @param [Mihari::Enrichers::IPinfo] enricher
#
# @return [Mihari::Geolocation, nil]
#
def build_by_ip(ip, enricher: Enrichers::IPInfo.new)
- result = enricher.query_result(ip).bind do |res|
+ result = enricher.result(ip).bind do |res|
value = res&.country_code
if value.nil?
Success nil
else
Success new(country: NormalizeCountry(value, to: :short), country_code: value)