[#1421] Move type specific to_s implementations to typed champs
This commit is contained in:
parent
c2f199c5aa
commit
ee8616fb97
3 changed files with 15 additions and 8 deletions
|
@ -67,14 +67,7 @@ class Champ < ApplicationRecord
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
if value.present?
|
if value.present?
|
||||||
case type_champ
|
string_value
|
||||||
when 'date'
|
|
||||||
Date.parse(value).strftime('%d/%m/%Y')
|
|
||||||
when 'multiple_drop_down_list'
|
|
||||||
drop_down_list.selected_options_without_decorator(self).join(', ')
|
|
||||||
else
|
|
||||||
value.to_s
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
@ -118,4 +111,10 @@ class Champ < ApplicationRecord
|
||||||
|
|
||||||
errors
|
errors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def string_value
|
||||||
|
value.to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,4 +11,8 @@ class Champs::DateChamp < Champ
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def string_value
|
||||||
|
Date.parse(value).strftime('%d/%m/%Y')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,4 +14,8 @@ class Champs::MultipleDropDownListChamp < Champ
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def string_value
|
||||||
|
drop_down_list.selected_options_without_decorator(self).join(', ')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue