Class: SportDb::Sync::Country
- Inherits:
-
Object
- Object
- SportDb::Sync::Country
- Defined in:
- lib/sportdb/readers/sync/country.rb
Class Method Summary collapse
Class Method Details
.find(country) ⇒ Object
finders
8 9 10 |
# File 'lib/sportdb/readers/sync/country.rb', line 8 def self.find( country ) WorldDb::Model::Country.find_by( key: country.key ) end |
.find!(country) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/sportdb/readers/sync/country.rb', line 12 def self.find!( country ) rec = find( country ) if rec.nil? puts "** !!! ERROR !!! - country for key >#{country.key}< not found; sorry - add to COUNTRIES table" exit 1 end rec end |
.find_or_create(country) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sportdb/readers/sync/country.rb', line 21 def self.find_or_create( country ) rec = find( country ) if rec.nil? attribs = { key: country.key, name: country.name, code: country.code, ## fix: uses fifa code now (should be iso-alpha3 if available) ## fifa: country.fifa, area: 1, pop: 1 } rec = WorldDb::Model::Country.create!( attribs ) end rec end |