refactor: move serializer

This commit is contained in:
simon lehericey 2023-03-24 11:10:39 +01:00 committed by Eric Leroy-Terquem
parent 0ca7c805df
commit bf737edec1
3 changed files with 15 additions and 30 deletions

View file

@ -82,19 +82,5 @@ class GroupeInstructeur < ApplicationRecord
procedure.update!(routing_enabled: procedure.groupe_instructeurs.active.many?)
end
class RoutingSerializer
def self.load(routing)
if routing.present?
Logic.from_h(routing)
end
end
def self.dump(routing)
if routing.present?
routing.to_h
end
end
end
serialize :routing, RoutingSerializer
serialize :routing_rule, LogicSerializer
end

View file

@ -141,21 +141,7 @@ class TypeDeChamp < ApplicationRecord
serialize :options, WithIndifferentAccess
class ConditionSerializer
def self.load(condition)
if condition.present?
Logic.from_h(condition)
end
end
def self.dump(condition)
if condition.present?
condition.to_h
end
end
end
serialize :condition, ConditionSerializer
serialize :condition, LogicSerializer
after_initialize :set_dynamic_type
after_create :populate_stable_id

View file

@ -0,0 +1,13 @@
class LogicSerializer
def self.load(logic)
if logic.present?
Logic.from_h(logic)
end
end
def self.dump(logic)
if logic.present?
logic.to_h
end
end
end