Class: Clickwrap::IpGeolocation::NullResolver

Inherits:
Resolver
  • Object
show all
Defined in:
lib/clickwrap/ip_geolocation/null_resolver.rb

Overview

The resolver Clickwrap uses when the host configured none.

It exists so that "no IP geolocation provider is installed" is an ordinary answer with a reason on it, rather than a branch that has to be handled separately everywhere. Every capture path runs the same code; a host with no geolocation gem gets ip_geolocation_unavailable_reason set to no_resolver_configured, which is a true statement about the application and reads correctly on a receipt years later.

That also means the entire request-evidence feature — policies, field allowlists, retention, receipts, disposal — is testable and reviewable without a provider account, a database download, or a network call.

A policy that authorizes IP-geolocation fields while no resolver is configured is caught earlier, by Configuration#validate!, with a sentence saying so. This resolver is the safety net under that check, not a way to pretend the configuration is fine.

Constant Summary collapse

REASON =
"no_resolver_configured"

Instance Method Summary collapse

Instance Method Details

#capabilitiesObject

Nothing. Not "everything but it always fails" — a host reading capabilities is asking what this resolver could ever supply, and the honest answer is no field at all.



32
# File 'lib/clickwrap/ip_geolocation/null_resolver.rb', line 32

def capabilities = [].freeze

#resolve(_ip_address, http_request: nil) ⇒ Object



25
26
27
# File 'lib/clickwrap/ip_geolocation/null_resolver.rb', line 25

def resolve(_ip_address, http_request: nil)
  Location.unavailable(reason: REASON)
end