Sha256: 51657d4205232818a7ed09bedf70401482e8c26ac20d8990617663049026ae58
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
class Entry < ActiveRecord::Base belongs_to :user belongs_to :pool validates_uniqueness_of :name validates_presence_of :tie_break validates_presence_of :user_id # Override bracket to resolve the db blob to an object def bracket unless @bracket if self[:data] @bracket = Marshal.load(self[:data]) end @bracket ||= Tournament::Bracket.new(self.pool.pool.tournament_entry.picks.teams) end @bracket end def reset @bracket = Tournament::Bracket.new(self.pool.pool.tournament_entry.picks.teams) end def before_save if @bracket logger.debug("MARSHALLING BRACKET: #{@bracket.inspect}") self[:data] = Marshal.dump(@bracket) logger.debug("DONE MARSHALLING BRACKET") end end def after_save if self.bracket.complete? && self.user_id != self.pool.user_id self.pool.pool.update_entry(self.tournament_entry) self.pool.save! end end def tournament_entry @tournament_entry ||= Tournament::Entry.new(self.name, self.bracket, self.tie_break) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tournament-2.1.0 | webgui/app/models/entry.rb |
tournament-2.0.0 | webgui/app/models/entry.rb |