refactor(champ): remove call to validation from value formatting code
This commit is contained in:
parent
f954d07cf6
commit
133689b4d3
4 changed files with 4 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue