class SportDb::Sync::Team
Public Class Methods
__find_or_create( team )
click to toggle source
# File lib/sportdb/sync/sync.rb, line 52 def self.__find_or_create( team ) ## todo/check: use find_or_create_worker instead of _find - why? why not? rec = if team.is_a?( Import::NationalTeam ) NationalTeam.find_or_create( team ) else ## assume Club Club.find_or_create( team ) end cache[ team.name ] = rec ## note: assume "canonical" unique team name rec end
cache()
click to toggle source
auto-cache all clubs by find_or_create
for later mapping / lookup
# File lib/sportdb/sync/sync.rb, line 36 def self.cache() @cache ||= {}; end
find_or_create( team_or_teams )
click to toggle source
# File lib/sportdb/sync/sync.rb, line 38 def self.find_or_create( team_or_teams ) if team_or_teams.is_a?( Array ) recs = [] teams = team_or_teams teams.each do |team| recs << __find_or_create( team ) end recs else # assome single rec team = team_or_teams __find_or_create( team ) end end