app/models/rubric_criterion.rb
# Checks whether the passed in param's level_attributes have unique name and marks.
# Skips the uniqueness validation if true.
Checks whether the passed in param's level_attributes have unique name and marks.
Skips the uniqueness validation if true.
Checks whether the passed in param ' s level_attributes have unique name and marks . Skips the uniqueness validation if true .
def update_levels(levels_attributes)
    s1, s2 = Set[], Set[]
    should_skip = true
    levels_attributes.each do |_key, val|
      if s1.include?(val[:mark]) || s2.include?(val[:name])
        should_skip = false
        break
      end
      s1.add(val[:mark])
      s2.add(val[:name])
    end
    if should_skip
      levels_attributes.each do |_key, val|
        val[:skip_uniqueness_validation] = true
      end
    end
    self.update(levels_attributes: levels_attributes)
  end
def update_levels ( levels_attributes ) s1 , s2 = Set [ ] , Set [ ] should_skip = true levels_attributes . each do | _key , val | if s1 . include? ( val [ :mark ] ) || s2 . include? ( val [ :name ] ) should_skip = false break end s1 . add ( val [ :mark ] ) s2 . add ( val [ :name ] ) end if should_skip levels_attributes . each do | _key , val | val [ :skip_uniqueness_validation ] = true end end self . update ( levels_attributes : levels_attributes ) end
Checks whether the passed in param's level_attributes have unique name and marks.
Checks whether the passed in param ' s level_attributes have unique name and marks .
# Check if there's a dup in marks or names
levels_attributes
<not_specific>