Sha256: 2038e60dc5fd1245a5008aa200147975ce4c50ec29c3376fdb721b4d89da8687
Contents?: true
Size: 687 Bytes
Versions: 6
Compression:
Stored size: 687 Bytes
Contents
# frozen_string_literal: true require "normalize_country" module Mihari class Geolocation < ActiveRecord::Base belongs_to :artifact class << self include Dry::Monads[:result] # # Build Geolocation # # @param [String] ip # # @return [Mihari::Geolocation, nil] # def build_by_ip(ip) result = Enrichers::IPInfo.query_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) end end result.value_or nil end end end end
Version data entries
6 entries across 6 versions & 1 rubygems