docbrown/lib/ISO3166/country.rb
PJ 7be865b295
Feature-flagged support for filtering billboards by location (#19834)
* add migrations

* add countries gem?

* first pass at location model

* specs 

* add location to filtered ads query

* feature flag and nicer errors

* cosmetic fixes

* more tweaks (remove unnecessary index, add initializer)
2023-07-27 18:13:26 +01:00

18 lines
517 B
Ruby

# Modifications to the `countries` gem for clearer application code.
# In the future, we might want to modify the gem's dataset here (e.g. to include
# a mapping of the relationship between hierarchical subdivisions)
module ISO3166
class Country
def self.code_from_name(name)
find_country_by_any_name(name).alpha2
end
def self.region_codes_if_exists(alpha2_code)
new(alpha2_code)&.region_codes || []
end
def region_codes
@region_codes ||= subdivisions.keys
end
end
end