refactor: move serializer
This commit is contained in:
parent
0ca7c805df
commit
bf737edec1
3 changed files with 15 additions and 30 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
13
app/serializers/logic_serializer.rb
Normal file
13
app/serializers/logic_serializer.rb
Normal 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
|
Loading…
Add table
Reference in a new issue