refactor(type de champ): extract routable? method

This commit is contained in:
Eric Leroy-Terquem 2023-09-15 09:50:29 +02:00
parent cdeddc6e1e
commit 956048ffea
2 changed files with 12 additions and 1 deletions

View file

@ -224,7 +224,7 @@ class ProcedureRevision < ApplicationRecord
end end
def routable_types_de_champ def routable_types_de_champ
types_de_champ_public.filter { |tdc| [:drop_down_list, :departements, :regions, :communes].include?(tdc.type_champ.to_sym) } types_de_champ_public.filter(&:routable?)
end end
private private

View file

@ -98,6 +98,13 @@ class TypeDeChamp < ApplicationRecord
cojo: 'cojo' cojo: 'cojo'
} }
ROUTABLE_TYPES = [
type_champs.fetch(:drop_down_list),
type_champs.fetch(:communes),
type_champs.fetch(:departements),
type_champs.fetch(:regions)
]
store_accessor :options, store_accessor :options,
:cadastres, :cadastres,
:old_pj, :old_pj,
@ -566,6 +573,10 @@ class TypeDeChamp < ApplicationRecord
end end
end end
def routable?
type_champ.in?(ROUTABLE_TYPES)
end
private private
DEFAULT_EMPTY = [''] DEFAULT_EMPTY = ['']