Permalink
Browse files

cleanup models

  • Loading branch information...
1 parent 564ce43 commit 1351bd7c971947c1cfaf68c53a67439844f5ecf5 @geraldb geraldb committed Nov 14, 2012
Showing with 16 additions and 56 deletions.
  1. +6 −4 app/models/round.rb
  2. +2 −6 app/models/service.rb
  3. +7 −41 app/models/team.rb
  4. +1 −1 config/environment.rb
  5. +0 −4 lib/quotes.rb
View
@@ -16,14 +16,16 @@
# updated_at :datetime not null
#
+module SportDB::Models
-class Round < ActiveRecord::Base
+class Round
- has_many :games, :order => 'pos'
- belongs_to :event
-
def calc? # todo/fix: already supported by default by framework? check
calc == true
end
end # class Round
+
+end # module SportDB::Models
+
+Round = SportDB::Models::Round
View
@@ -1,7 +1,3 @@
-class Service < ActiveRecord::Base
-
- has_many :event_quotes, :order => 'odds' # event_(team_winner)_quotes
- has_many :group_quotes, :order => 'odds' # group_(team_winner)_quotes
-
-end # class Service
+
+Service = SportDB::Models::Service
View
@@ -17,15 +17,9 @@
#
-class Team < ActiveRecord::Base
+module SportDB::Models
- has_many :home_games, :class_name => 'Game', :foreign_key => 'team1_id'
- has_many :away_games, :class_name => 'Game', :foreign_key => 'team2_id'
-
- ### fix - how to do it with has_many macro? possible??
- def games
- Game.where( 'team1_id = ? or team2_id = ?', id, id ).order( 'play_at' ).all
- end
+class Team
def self.update_image_from_ary!( teams )
teams.each do |values|
@@ -41,41 +35,13 @@ def self.update_image_from_ary!( teams )
end # each team
end
- def self.create_from_ary!( teams )
- teams.each do |values|
-
- ## key & title required
- attr = {
- :key => values[0],
- :title => values[1]
- }
-
- ## check for optional values
- values[2..-1].each do |value|
- if value.length == 3 ## assume its a tag (three latters)
- attr[ :tag ] = value
- ## fix: use a regex pattern?
- elsif value.include?( '.png' ) || value.include?( '.jpg' ) || value.include?( '.gif' ) ## assume its a img
- attr[ :img ] = value
- else
- attr[ :title2 ] = value
- end
- end
-
- Team.create!( attr )
- end # each team
- end
-
-
def calc?
calc == true
end
-
- def key
- # generate key if necessary (for debugging only - should be not null field!)
- value = read_attribute(:key)
- value = "?#{title.downcase.gsub( /\s/, '_').gsub( /[^a-z0-9_]/, '*' )}?" if value.blank?
- value
- end
end # class Team
+
+end # module SportDB::Models
+
+Team = SportDB::Models::Team
+
View
@@ -10,4 +10,4 @@
require "#{Rails.root}/lib/lookups.rb"
require "#{Rails.root}/lib/backup.rb"
require "#{Rails.root}/lib/recalc.rb"
-require "#{Rails.root}/lib/quotes.rb"
+
View
@@ -1,4 +0,0 @@
-
-# todo: delete file
-
-# code moved to sport.db-market plugin

0 comments on commit 1351bd7

Please sign in to comment.