Class: Merit::Sash
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Merit::Sash
- Includes:
- Base::Sash, Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/merit/models/mongoid/merit/sash.rb,
lib/merit/models/active_record/merit/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.
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 Base::Sash
#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
22 23 24 25 26 27 28 |
# File 'lib/merit/models/mongoid/merit/sash.rb', line 22 def score_points( = {}) scope = scores if (category = [:category]) scope = scope.where(category: category) end Merit::Score::Point.where(:score_id.in => scope.map(&:_id)) end |