Sha256: e9af509ae0bab9d510d4f98d1950f95eb4d7b3381aea2e95b4953109e2be8dd6
Contents?: true
Size: 583 Bytes
Versions: 9
Compression:
Stored size: 583 Bytes
Contents
class User include Mongoid::Document include Mongoid::Timestamps has_merit field :name has_many :comments attr_accessible :name def show_badges create_sash_if_none badges_uniq = Badge.find_by_id(sash.badge_ids) badges_uniq.collect{|b| "#{b.name.capitalize}#{badge_status(b)}" }.join(', ') end def badge_status(badge) status = [] count = badges.select{|b| b.name == badge.name }.count status << "level: #{badge.level}" if badge.level status << "x#{count}" if count > 1 status.present? ? " (#{status.join(', ')})" : '' end end
Version data entries
9 entries across 9 versions & 1 rubygems