From 55419b92a81457cd30cfa33708b4601854111ae1 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Fri, 28 Dec 2018 18:12:12 +0100 Subject: [PATCH] Simplify code --- app/models/champs/carte_champ.rb | 2 +- app/models/champs/decimal_number_champ.rb | 2 +- app/models/champs/integer_number_champ.rb | 2 +- app/models/champs/multiple_drop_down_list_champ.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/champs/carte_champ.rb b/app/models/champs/carte_champ.rb index e03f9e2e7..7992d50e1 100644 --- a/app/models/champs/carte_champ.rb +++ b/app/models/champs/carte_champ.rb @@ -90,6 +90,6 @@ class Champs::CarteChamp < Champ end def for_api - geo_json.present? ? geo_json.to_json : nil + geo_json&.to_json end end diff --git a/app/models/champs/decimal_number_champ.rb b/app/models/champs/decimal_number_champ.rb index 688f8f57b..199e38079 100644 --- a/app/models/champs/decimal_number_champ.rb +++ b/app/models/champs/decimal_number_champ.rb @@ -12,6 +12,6 @@ class Champs::DecimalNumberChamp < Champ private def processed_value - value.present? ? value.to_f : nil + value&.to_f end end diff --git a/app/models/champs/integer_number_champ.rb b/app/models/champs/integer_number_champ.rb index c62405b78..4717c24df 100644 --- a/app/models/champs/integer_number_champ.rb +++ b/app/models/champs/integer_number_champ.rb @@ -12,6 +12,6 @@ class Champs::IntegerNumberChamp < Champ private def processed_value - value.present? ? value.to_i : nil + value&.to_i end end diff --git a/app/models/champs/multiple_drop_down_list_champ.rb b/app/models/champs/multiple_drop_down_list_champ.rb index dc13aa8d7..ef72e07b4 100644 --- a/app/models/champs/multiple_drop_down_list_champ.rb +++ b/app/models/champs/multiple_drop_down_list_champ.rb @@ -10,7 +10,7 @@ class Champs::MultipleDropDownListChamp < Champ end def to_s - value.present? ? selected_options.join(', ') : '' + selected_options.join(', ') end def for_export