Class: Workarea::Segment::Rules::Geolocation
- Inherits:
-
Base
- Object
- Base
- Workarea::Segment::Rules::Geolocation
show all
- Defined in:
- app/models/workarea/segment/rules/geolocation.rb
Instance Method Summary
collapse
Methods inherited from Base
slug
#releasable?
add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list
#embedded_children
Instance Method Details
#matchable_locations_for(visit) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'app/models/workarea/segment/rules/geolocation.rb', line 17
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
|
#qualifies?(visit) ⇒ Boolean
7
8
9
10
11
12
13
14
15
|
# File 'app/models/workarea/segment/rules/geolocation.rb', line 7
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
|