Class: Merit::Models::ActiveRecord::Sash
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Merit::Models::ActiveRecord::Sash
- Includes:
- SashConcern
- Defined in:
- lib/merit/models/active_record/sash.rb
Overview
Sash is a container for reputation data for meritable models. It’s an indirection between meritable models and badges and scores (one to one relationship).
It’s existence make join models like badges_users and scores_users unnecessary. It should be transparent at the application.
Direct Known Subclasses
Instance Method Summary collapse
-
#score_points(options = {}) ⇒ ActiveRecord::Relation
Retrieve all points from a category or none if category doesn’t exist By default retrieve all Points.
Methods included from SashConcern
#add_badge, #add_points, #badge_ids, #badges, #points, #rm_badge, #subtract_points
Instance Method Details
#score_points(options = {}) ⇒ ActiveRecord::Relation
Retrieve all points from a category or none if category doesn’t exist By default retrieve all Points
24 25 26 27 28 29 30 31 32 |
# File 'lib/merit/models/active_record/sash.rb', line 24 def score_points( = {}) scope = Merit::QalamScore::Point .joins(:score) .where('merit_scores.sash_id = ?', id) if (category = [:category]) scope = scope.where('merit_scores.category = ?', category) end scope end |