Module: Competition::ClassMethods
- Defined in:
- lib/competition.rb
Constant Summary collapse
- @@score_with =
nil
- @@score_if =
nil
- @@score_amount =
nil
Instance Method Summary collapse
- #has_score ⇒ Object
- #keeps_score(options = {}) ⇒ Object
- #score_amount ⇒ Object
- #score_if ⇒ Object
- #score_with ⇒ Object
Instance Method Details
#has_score ⇒ Object
11 12 13 14 15 |
# File 'lib/competition.rb', line 11 def has_score self.class_eval { has_one :score, :as => :scoreable, :class_name => "Competition::Score" } end |
#keeps_score(options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/competition.rb', line 17 def keeps_score ={} self.class_eval { has_many :score_entries, :as => :score_entryable, :class_name => "Competition::ScoreEntry" } [:on].each do |event| case event when :create self.class_eval { after_create :add_score } when :update self.class_eval { after_save :add_score } end end @@score_with = [:for] @@score_if = [:if] @@score_amount = [:amount] end |
#score_amount ⇒ Object
47 48 49 |
# File 'lib/competition.rb', line 47 def score_amount @@score_amount end |
#score_if ⇒ Object
43 44 45 |
# File 'lib/competition.rb', line 43 def score_if @@score_if end |
#score_with ⇒ Object
39 40 41 |
# File 'lib/competition.rb', line 39 def score_with @@score_with end |