refactor(champ): remove call to validation from value formatting code

This commit is contained in:
Paul Chavard 2024-07-08 11:42:40 +02:00
parent f954d07cf6
commit 133689b4d3
No known key found for this signature in database
4 changed files with 4 additions and 9 deletions

View file

@ -107,11 +107,6 @@ class Champ < ApplicationRecord
[to_s]
end
def valid_value
return unless valid_champ_value?
value
end
def to_s
TypeDeChamp.champ_value(type_champ, self)
end

View file

@ -20,7 +20,7 @@ class TypesDeChamp::DecimalNumberTypeDeChamp < TypesDeChamp::TypeDeChampBase
private
def champ_formatted_value(champ)
champ.valid_value&.to_f
champ.value&.to_f
end
end
end

View file

@ -20,7 +20,7 @@ class TypesDeChamp::IntegerNumberTypeDeChamp < TypesDeChamp::TypeDeChampBase
private
def champ_formatted_value(champ)
champ.valid_value&.to_i
champ.value&.to_i
end
end
end

View file

@ -66,12 +66,12 @@ class TypesDeChamp::TypeDeChampBase
when 2
champ_value(champ)
else
champ.valid_value.presence || champ_default_api_value(version)
champ.value.presence || champ_default_api_value(version)
end
end
def champ_value_for_export(champ, path = :value)
path == :value ? champ.valid_value.presence : champ_default_export_value(path)
path == :value ? champ.value.presence : champ_default_export_value(path)
end
def champ_value_for_tag(champ, path = :value)