Sha256: a7a861adad6d724b5af17a8b9cfa460ddc0e4e8b02fcaae175f8370432961847
Contents?: true
Size: 835 Bytes
Versions: 1
Compression:
Stored size: 835 Bytes
Contents
# frozen_string_literal: true require "normalize_country" module Mihari module Models class Geolocation < ActiveRecord::Base belongs_to :artifact class << self include Dry::Monads[:result] # # Build Geolocation # # @param [String] ip # @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| 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.6.2 | lib/mihari/models/geolocation.rb |