Sha256: 0e3db8d84f00028d98e7431ffdeb7837101a3f74a5cda39190e980386b31f682
Contents?: true
Size: 831 Bytes
Versions: 28
Compression:
Stored size: 831 Bytes
Contents
module Workarea class Segment module Rules class Geolocation < Base field :locations, type: Array, default: [] def qualifies?(visit) return false if locations.blank? visit_locations = matchable_locations_for(visit) return false if visit_locations.blank? matchable_locations = locations.map(&:downcase) visit_locations.any? { |l| l.in?(matchable_locations) } end def matchable_locations_for(visit) option_ids = [ visit.postal_code, GeolocationOption.from_subdivision(visit.country, visit.subdivision)&.id, GeolocationOption.from_country(visit.country)&.id ] (visit.location_names + option_ids).reject(&:blank?).map(&:downcase) end end end end end
Version data entries
28 entries across 28 versions & 1 rubygems