refactor(column): no more java 🎉 get_value -> value

This commit is contained in:
Paul Chavard 2024-10-31 21:36:13 +01:00
parent af33e6a0e9
commit 7fddec484d
No known key found for this signature in database
6 changed files with 26 additions and 40 deletions

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
class Columns::DossierColumn < Column
def get_value(dossier)
def value(dossier)
case table
when 'self'
dossier.public_send(column)

View file

@ -25,14 +25,10 @@ class Columns::JSONPathColumn < Column
private
def get_raw_value(champ)
def typed_value(champ)
champ.value_json&.dig(*value_column)
end
def should_cast?
false
end
def stable_id
@column
end

View file

@ -2,11 +2,8 @@
class Columns::LinkedDropDownColumn < Column
def column
if value_column == :value
super
else
"#{@column}->#{value_column}" # override column otherwise json path facets will have same id as other
end
return super if default_column?
"#{@column}->#{value_column}" # override column otherwise json path facets will have same id as other
end
def filtered_ids(dossiers, values)
@ -17,11 +14,11 @@ class Columns::LinkedDropDownColumn < Column
private
def get_raw_value(champ)
def typed_value(champ)
return nil if default_column?
primary_value, secondary_value = unpack_values(champ.value)
case value_column
when :value
nil
when :primary
primary_value
when :secondary
@ -29,10 +26,6 @@ class Columns::LinkedDropDownColumn < Column
end
end
def should_cast?
false
end
def unpack_values(value)
JSON.parse(value)
rescue JSON::ParserError

View file

@ -3,7 +3,7 @@
class Columns::TitreIdentiteColumn < Column
private
def get_raw_value(champ)
champ.piece_justificative_file.attached?.to_s
def typed_value(champ)
champ.piece_justificative_file.attached?
end
end