lib/sportdb/models/game.rb in sportdb-1.5.0 vs lib/sportdb/models/game.rb in sportdb-1.6.0
- old
+ new
@@ -1,6 +1,6 @@
-module SportDB::Models
+module SportDb::Models
class Game < ActiveRecord::Base
belongs_to :team1, :class_name => 'Team', :foreign_key => 'team1_id'
@@ -9,11 +9,46 @@
belongs_to :round
belongs_to :group # group is optional
before_save :calc_toto12x
+ ### getter/setters for deprecated attribs (score3,4,5,6) n national
+
+ def score3
+ score1ot
+ end
+ def score4
+ score2ot
+ end
+
+ def score5
+ score1p
+ end
+
+ def score6
+ score2p
+ end
+
+ def score3=(value)
+ self.score1ot = value
+ end
+
+ def score4=(value)
+ self.score2ot = value
+ end
+
+ def score5=(value)
+ self.score1p = value
+ end
+
+ def score6=(value)
+ self.score2p = value
+ end
+
+
+
def self.create_knockouts_from_ary!( games, round )
Game.create_from_ary!( games, round, true )
end
def self.create_from_ary!( games, round, knockout=false )
@@ -56,14 +91,14 @@
:round => round,
:pos => value_pos,
:team1 => value_teams[0],
:score1 => value_scores[0],
:score2 => value_scores[1],
- :score3 => value_scores[2],
- :score4 => value_scores[3],
- :score5 => value_scores[4],
- :score6 => value_scores[5],
+ :score1ot => value_scores[2],
+ :score2ot => value_scores[3],
+ :score1p => value_scores[4],
+ :score2p => value_scores[5],
:team2 => value_teams[1],
:play_at => value_play_at,
:group => value_group, # Note: group is optional (may be null/nil)
:knockout => value_knockout )
end # each games
@@ -120,14 +155,14 @@
:round =>round2,
:pos =>pair[1][0],
:team1 =>pair[1][1],
:score1 =>pair[1][2][0],
:score2 =>pair[1][2][1],
- :score3 =>pair[1][2][2],
- :score4 =>pair[1][2][3],
- :score5 =>pair[1][2][4],
- :score6 =>pair[1][2][5],
+ :score1ot =>pair[1][2][2],
+ :score2ot =>pair[1][2][3],
+ :score1p =>pair[1][2][4],
+ :score1p =>pair[1][2][5],
:team2 =>pair[1][3],
:play_at =>pair[1][4],
:knockout =>true }
game1 = Game.create!( game1_attribs )
@@ -192,6 +227,6 @@
end # class Game
-end # module SportDB::Models
+end # module SportDb::Models