module Merit::PointRulesMethods
Points are a simple integer value which are given to “meritable” resources according to rules in app/models/merit/point_rules.rb
. They are given on actions-triggered.
Public Instance Methods
defined_rules()
click to toggle source
Currently defined rules
# File lib/merit/point_rules_methods.rb, line 29 def defined_rules @defined_rules ||= {} end
score(points, *args, &block)
click to toggle source
Define rules on certaing actions for giving points
# File lib/merit/point_rules_methods.rb, line 7 def score(points, *args, &block) options = args.extract_options! options_to = options.fetch(:to) { :action_user } actions = Array.wrap(options[:on]) Array.wrap(options_to).each do |to| rule = Rule.new rule.score = points rule.to = to rule.block = block rule.category = options.fetch(:category) { :default } rule.model_name = options[:model_name] if options[:model_name] actions.each do |action| defined_rules[action] ||= [] defined_rules[action] << rule end end end