Sha256: 3636a23c0afdb230d3736b4c9647480573e56d08abfb2517d0023c66a5a81329

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

# 5 stars is a common ranking use case. They are not given at specified
# actions like badges, you should define a cron job to test if ranks are to be
# granted.
#
# +set_rank+ accepts:
# * :+level+ ranking level (greater is better)
# * :+to+ model or scope to check if new rankings apply
# * :+level_name+ attribute name (default is empty and results in 'level'
#   attribute, if set it's appended like 'level_#{level_name}')

module Merit
  class RankRules
    def initialize
      # i stars for i chars name
      (1..5).each do |i|
        set_rank :level => i, :to => User do |user|
          user.name.length == i
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
merit-0.6.0 test/dummy/app/models/merit/rank_rules.rb