Class: SportDb::Sync::Season

Inherits:
Object
  • Object
show all
Defined in:
lib/sportdb/readers/sync/season.rb

Class Method Summary collapse

Class Method Details

.find(season) ⇒ Object

finders



8
9
10
11
# File 'lib/sportdb/readers/sync/season.rb', line 8

def self.find( season )
  season = Season( season )     ## auto-convert for now (for old compat) - why? why not?
  Model::Season.find_by( key: season.key )
end

.find!(season) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/sportdb/readers/sync/season.rb', line 13

def self.find!( season )
  season = Season( season )     ## auto-convert for now (for old compat) - why? why not?
  rec = find( season )
  if rec.nil?
    puts "** !!!ERROR!!! db sync - no season match found for >#{season.key}<:"
    exit 1
  end
  rec
end

.find_or_create(season) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/sportdb/readers/sync/season.rb', line 23

def self.find_or_create( season )
  season = Season( season )    ## auto-convert for now (for old compat) - why? why not?
  rec = find( season )
  if rec.nil?
     attribs = { key:   season.key,
                 name:  season.name  }
     rec = Model::Season.create!( attribs )
  end
  rec
end