mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make code simpler to read by using a case statement
This commit is contained in:
parent
12815e0d44
commit
70161ae3b8
1 changed files with 6 additions and 2 deletions
|
@ -44,8 +44,12 @@ module ActiveModel
|
|||
record.errors.add(attr_name, option, filtered_options(value))
|
||||
end
|
||||
else
|
||||
option_value = option_value.call(record) if option_value.is_a?(Proc)
|
||||
option_value = record.send(option_value) if option_value.is_a?(Symbol)
|
||||
case option_value
|
||||
when Proc
|
||||
option_value = option_value.call(record)
|
||||
when Symbol
|
||||
option_value = record.send(option_value)
|
||||
end
|
||||
|
||||
unless value.send(CHECKS[option], option_value)
|
||||
record.errors.add(attr_name, option, filtered_options(value).merge!(count: option_value))
|
||||
|
|
Loading…
Reference in a new issue