Class: Cb::Utils::Country

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/utils/country.rb

Class Method Summary collapse

Class Method Details

.get_supportedObject

These aren’t all country codes. We get it. Our naming scheme didn’t hold up over time.



5
6
7
8
9
# File 'lib/cb/utils/country.rb', line 5

def self.get_supported
  %w(AH BE CA CC CE CH CN CP CS CY DE DK E1 ER ES EU F1
   FR GC GR I1 IE IN IT J1 JC JS LJ M1 MY NL NO PD PI
   PL RM RO RX S1 SE SF SG T1 T2 UK US WH WM WR)
end

.inject_convenience_methodsObject



15
16
17
18
19
20
21
22
23
# File 'lib/cb/utils/country.rb', line 15

def self.inject_convenience_methods
  get_supported.each do |country|
    unless self.respond_to? "#{country}"
      self.define_singleton_method "#{country}" do
        return country
      end
    end
  end
end

.is_valid?(country) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/cb/utils/country.rb', line 11

def self.is_valid?(country)
  get_supported.include? country
end