Class: CountryStateSelect::DataSources::CityState
- Defined in:
- lib/country_state_select/data_sources/city_state.rb
Overview
Default adapter, backed by the city-state gem (unchanged behavior
from 3.x). CS.countries returns a Hash memoized for the whole
process, so every read here is non-mutating.
Instance Method Summary collapse
Instance Method Details
#cities(state_code, country_code) ⇒ Object
21 22 23 24 25 |
# File 'lib/country_state_select/data_sources/city_state.rb', line 21 def cities(state_code, country_code) return [] if state_code.nil? || state_code.to_s.empty? CS.cities(state_code.to_sym, country_code.to_s.empty? ? nil : country_code.to_sym) || [] end |
#countries ⇒ Object
11 12 13 |
# File 'lib/country_state_select/data_sources/city_state.rb', line 11 def countries CS.countries.reject { |k, _| k == :COUNTRY_ISO_CODE } end |
#states(country_code) ⇒ Object
15 16 17 18 19 |
# File 'lib/country_state_select/data_sources/city_state.rb', line 15 def states(country_code) return [] if country_code.nil? || country_code.to_s.empty? (CS.states(country_code) || {}).to_a end |