refactor(type de champ): extract routable? method
This commit is contained in:
parent
cdeddc6e1e
commit
956048ffea
2 changed files with 12 additions and 1 deletions
|
@ -224,7 +224,7 @@ class ProcedureRevision < ApplicationRecord
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
private
|
||||
|
|
|
@ -98,6 +98,13 @@ class TypeDeChamp < ApplicationRecord
|
|||
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,
|
||||
:cadastres,
|
||||
:old_pj,
|
||||
|
@ -566,6 +573,10 @@ class TypeDeChamp < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def routable?
|
||||
type_champ.in?(ROUTABLE_TYPES)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
DEFAULT_EMPTY = ['']
|
||||
|
|
Loading…
Reference in a new issue