Sha256: 8c375e522879f0be4ee91fd18f180e57b2127b27741ee71a0a3090d2495dbf49
Contents?: true
Size: 1.21 KB
Versions: 13
Compression:
Stored size: 1.21 KB
Contents
module SportDb module Import class TeamIndex ## note: "virtual" index lets you search clubs and/or national_teams (don't care) def catalog() Import.catalog; end ## todo/check: rename to/use map_by! for array version - why? why not? def find_by!( name:, league:, mods: nil ) if name.is_a?( Array ) recs = [] name.each do |q| recs << __find_by!( name: q, league: league, mods: mods ) end recs else ## assume single name __find_by!( name: name, league: league, mods: mods ) end end def __find_by!( name:, league:, mods: nil ) if mods && mods[ league.key ] && mods[ league.key ][ name ] mods[ league.key ][ name ] else if league.clubs? if league.intl? ## todo/fix: add intl? to ActiveRecord league!!! catalog.clubs.find!( name ) else ## assume clubs in domestic/national league tournament catalog.clubs.find_by!( name: name, country: league.country ) end else ## assume national teams (not clubs) catalog.national_teams.find!( name ) end end end # method __find_by! end # class TeamIndex end # module Import end # module SportDb
Version data entries
13 entries across 13 versions & 1 rubygems