Class: CountryStateSelect::DataSources::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/country_state_select/data_sources/base.rb

Overview

Adapter interface. Implement this to back CountryStateSelect with a different data provider (a database table, the countries gem, a remote API, ...) instead of the bundled city-state gem — this is what closes out issue #25 (limited/missing city data) without the gem itself owning the data problem.

Direct Known Subclasses

CityState

Instance Method Summary collapse

Instance Method Details

#cities(_state_code, _country_code) ⇒ Array<String>

Returns city names.

Returns:

  • (Array<String>)

    city names

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/country_state_select/data_sources/base.rb', line 22

def cities(_state_code, _country_code)
  raise NotImplementedError
end

#countriesHash{Symbol=>String}

Returns ISO code => English country name.

Returns:

  • (Hash{Symbol=>String})

    ISO code => English country name

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/country_state_select/data_sources/base.rb', line 12

def countries
  raise NotImplementedError
end

#states(_country_code) ⇒ Array<Array(Symbol,String)>

Returns raw [code, name] pairs.

Returns:

  • (Array<Array(Symbol,String)>)

    raw [code, name] pairs

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/country_state_select/data_sources/base.rb', line 17

def states(_country_code)
  raise NotImplementedError
end