Class: Country

Inherits:
Object
  • Object
show all
Defined in:
lib/workarea/ext/freedom_patches/country.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.search_for(value) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/workarea/ext/freedom_patches/country.rb', line 2

def self.search_for(value)
  all.detect do |country|
    country.alpha2.casecmp?(value.to_s) ||
      country.alpha3.casecmp?(value.to_s) ||
      country.name.casecmp?(value.to_s) ||
      country.unofficial_names.any? { |name| name.casecmp?(value.to_s) }
  end
end

Instance Method Details

#as_jsonObject

Without this, any Country objects put in JSON render much verbose



12
13
14
# File 'lib/workarea/ext/freedom_patches/country.rb', line 12

def as_json(*)
  alpha2
end