class Adminterface::Data::Countries
Constants
- PluginMissing
Attributes
locale[R]
options[R]
Public Class Methods
new(locale, options = {})
click to toggle source
# File lib/adminterface/data/countries.rb, line 10 def initialize(locale, options = {}) @locale = locale @options = options end
Public Instance Methods
call()
click to toggle source
# File lib/adminterface/data/countries.rb, line 15 def call raise_error if plugin_missing? countries end
Private Instance Methods
countries()
click to toggle source
# File lib/adminterface/data/countries.rb, line 22 def countries codes = ISO3166::Country.codes codes.map do |code| country = ISO3166::Country[code] { code: code, name: country.name, translated_name: country.translations[locale.downcase.to_s] || country.name } end.sort_by { |x| x[:name] } end
plugin_missing?()
click to toggle source
# File lib/adminterface/data/countries.rb, line 34 def plugin_missing? !Object.const_defined?("::CountrySelect") end
raise_error()
click to toggle source
# File lib/adminterface/data/countries.rb, line 38 def raise_error raise PluginMissing, "To use the :country input, please install a country_select plugin, like this one: https://github.com/stefanpenner/country_select" end