Module: Competition
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/competition.rb,
lib/competition/engine.rb,
lib/competition/version.rb,
app/models/competition/score.rb,
app/models/competition/score_entry.rb,
app/helpers/competition/application_helper.rb,
app/helpers/competition/leaderboard_helper.rb,
app/controllers/competition/application_controller.rb,
app/controllers/competition/leaderboard_controller.rb
Defined Under Namespace
Modules: ApplicationHelper, ClassMethods, LeaderboardHelper
Classes: ApplicationController, Engine, LeaderboardController, Score, ScoreEntry
Constant Summary
collapse
- VERSION =
"0.0.2"
Instance Method Summary
collapse
Instance Method Details
#add_score ⇒ Object
52
53
54
55
56
|
# File 'lib/competition.rb', line 52
def add_score
return unless score?
score = Competition::Score.find_or_create_by_scoreable_type_and_scoreable_id(score_with.class.to_s, score_with.id)
Competition::ScoreEntry.create(:amount => score_amount, :score_id => score.id, :score_entryable_type => self.class.to_s, :score_entryable_id => self.id )
end
|
#score? ⇒ Boolean
62
63
64
|
# File 'lib/competition.rb', line 62
def score?
@score_if ||= self.class.score_if.call(self)
end
|
#score_amount ⇒ Object
58
59
60
|
# File 'lib/competition.rb', line 58
def score_amount
@score_amount ||= self.class.score_amount.call(self)
end
|
#score_with ⇒ Object
66
67
68
|
# File 'lib/competition.rb', line 66
def score_with
@score_with ||= self.class.score_with.call(self)
end
|