Commit a4b843e9 authored by Matija Čupić's avatar Matija Čupić

Refactor outer anonymous function into a do block

parent e5d9f4a3
......@@ -6,7 +6,9 @@
class VariableDuplicatesValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if options[:scope]
scoped = value.group_by { |variable| Array(options[:scope]).map { |attr| variable.send(attr) } } # rubocop:disable GitlabSecurity/PublicSend
scoped = value.group_by do |variable|
Array(options[:scope]).map { |attr| variable.send(attr) } # rubocop:disable GitlabSecurity/PublicSend
end
scoped.each_value { |scope| validate_duplicates(record, attribute, scope) }
else
validate_duplicates(record, attribute, value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment