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

Version Path
merit-0.10.1 test/dummy-mongoid/app/models/user.rb
merit-0.10.0 test/dummy-mongoid/app/models/user.rb
merit-0.9.5 test/dummy-mongoid/app/models/user.rb
merit-0.9.4 test/dummy-mongoid/app/models/user.rb
merit-0.9.3 test/dummy-mongoid/app/models/user.rb
merit-0.9.2 test/dummy-mongoid/app/models/user.rb
merit-0.9.1 test/dummy-mongoid/app/models/user.rb
merit-0.9.0 test/dummy-mongoid/app/models/user.rb
merit-0.8.1 test/dummy-mongoid/app/models/user.rb