Use safe navigation instead of rescue nil

This commit is contained in:
Javi Martín
2019-10-26 20:12:12 +02:00
parent 88c70366a7
commit 1fc30eb1c0

View File

@@ -3,11 +3,11 @@ module Measurable
class_methods do class_methods do
def title_max_length def title_max_length
@title_max_length ||= (columns.find { |c| c.name == "title" }.limit rescue nil) || 80 @title_max_length ||= (columns.find { |c| c.name == "title" }&.limit) || 80
end end
def responsible_name_max_length def responsible_name_max_length
@responsible_name_max_length ||= (columns.find { |c| c.name == "responsible_name" }.limit rescue nil) || 60 @responsible_name_max_length ||= (columns.find { |c| c.name == "responsible_name" }&.limit) || 60
end end
def question_max_length def question_max_length