1
0
Fork 0
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:
Carlos Antonio da Silva 2013-11-15 00:19:28 -02:00
parent 12815e0d44
commit 70161ae3b8

View file

@ -44,8 +44,12 @@ module ActiveModel
record.errors.add(attr_name, option, filtered_options(value)) record.errors.add(attr_name, option, filtered_options(value))
end end
else else
option_value = option_value.call(record) if option_value.is_a?(Proc) case option_value
option_value = record.send(option_value) if option_value.is_a?(Symbol) when Proc
option_value = option_value.call(record)
when Symbol
option_value = record.send(option_value)
end
unless value.send(CHECKS[option], option_value) unless value.send(CHECKS[option], option_value)
record.errors.add(attr_name, option, filtered_options(value).merge!(count: option_value)) record.errors.add(attr_name, option, filtered_options(value).merge!(count: option_value))