class Minfraud::Model::IPAddress
Model
containing GeoIP2 data and the risk for the IP address.
Constants
- LANGUAGE_CODES
Attributes
risk[R]
This field contains the risk associated with the IP address. The value ranges from 0.01 to 99. A higher score indicates a higher risk.
@return [Float]
risk_reasons[R]
This field contains IPRiskReason
objects identifying the reasons why the IP address received the associated risk. This will be an empty array if there are no reasons.
@return [Array<Minfraud::Model::IPRiskReason>]
Public Class Methods
new(record, locales)
click to toggle source
@!visibility private
Calls superclass method
MaxMind::GeoIP2::Model::City::new
# File lib/minfraud/model/ip_address.rb, line 25 def initialize(record, locales) if record super(record, locales) else super({}, locales) end if record @location = Minfraud::Model::GeoIP2Location.new(record.fetch('location', nil)) else @location = Minfraud::Model::GeoIP2Location.new(nil) end if record @risk = record.fetch('risk', nil) else @risk = nil end @risk_reasons = [] if record && record.key?('risk_reasons') record['risk_reasons'].each do |r| @risk_reasons << Minfraud::Model::IPRiskReason.new(r) end end # Decorate objects with deprecated attributes and names for backwards # compatibility. Do this here rather than with the overhead of # subclasses/modules for them in the hope that one day we can delete # them. # These are named differently in maxmind-geoip2. @country.define_singleton_method(:is_in_european_union) { in_european_union? } @registered_country.define_singleton_method(:is_in_european_union) { in_european_union? } @represented_country.define_singleton_method(:is_in_european_union) { in_european_union? } @traits.define_singleton_method(:is_anonymous) { anonymous? } @traits.define_singleton_method(:is_anonymous_vpn) { anonymous_vpn? } @traits.define_singleton_method(:is_hosting_provider) { hosting_provider? } @traits.define_singleton_method(:is_public_proxy) { public_proxy? } @traits.define_singleton_method(:is_tor_exit_node) { tor_exit_node? } # Mashify turned each language code into an attribute, but # maxmind-geoip2 exposes the names as a hash. LANGUAGE_CODES.each do |c| if @city.names @city.names.define_singleton_method(c) { fetch(c.to_s, nil) } end if @continent.names @continent.names.define_singleton_method(c) { fetch(c.to_s, nil) } end if @country.names @country.names.define_singleton_method(c) { fetch(c.to_s, nil) } end if @registered_country.names @registered_country.names.define_singleton_method(c) { fetch(c.to_s, nil) } end if @represented_country.names @represented_country.names.define_singleton_method(c) { fetch(c.to_s, nil) } end @subdivisions.each do |s| if s.names s.names.define_singleton_method(c) { fetch(c.to_s, nil) } end end end # This attribute is deprecated. @country.define_singleton_method(:is_high_risk) { get('is_high_risk') } # These attributes are deprecated and aren't in maxmind-geoip2. @traits.define_singleton_method(:is_anonymous_proxy) { get('is_anonymous_proxy') } @traits.define_singleton_method(:is_satellite_provider) { get('is_satellite_provider') } end