app/models/merit_action.rb
# Check rules defined for a merit_action
Check rules defined for a merit_action
Check rules defined for a merit_action
def check_badge_rules(defined_rules)
    action_name = "#{target_model}\##{action_method}"
    unless had_errors
      if defined_rules[action_name].present?
        defined_rules[action_name].each do |rule|
          rule.grant_or_delete_badge(self)
        end
      end
      actions_to_point = MeritPointRules.new.actions_to_point
      if actions_to_point[action_name].present?
        point_rule = actions_to_point[action_name]
        point_rule[:to].each do |to|
          if to == :action_user
            if !(target = User.find_by_id(user_id))
              Rails.logger.warn "[merit] no user found to grant points"
              return
            end
          else
            begin
              target = target_object.send(to)
            rescue
              Rails.logger.warn "[merit] No target_object found on check_badge_rules."
              return
            end
          end
          target.update_attribute(:points, target.points + point_rule[:score])
        end
      end
    end
    processed!
  end
def check_badge_rules ( defined_rules ) action_name = "#{target_model}\##{action_method}" unless had_errors if defined_rules [ action_name ] . present? defined_rules [ action_name ] . each do | rule | rule . grant_or_delete_badge ( self ) end end actions_to_point = MeritPointRules . new . actions_to_point if actions_to_point [ action_name ] . present? point_rule = actions_to_point [ action_name ] point_rule [ :to ] . each do | to | if to == :action_user if ! ( target = User . find_by_id ( user_id ) ) Rails . logger . warn "[merit] no user found to grant points" return end else begin target = target_object . send ( to ) rescue Rails . logger . warn "[merit] No target_object found on check_badge_rules." return end end target . update_attribute ( :points , target . points + point_rule [ :score ] ) end end end processed! end
Check rules defined for a merit_action
Check rules defined for a merit_action
# Check Badge rules # Check Point rules
defined_rules
<not_specific>