From 02a72507b9fd92d41acd8c3d1898983660ab6c3c Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Mon, 11 Mar 2019 11:16:37 +0100 Subject: [PATCH] Remove compatibility code for legacy values in database column They were fixed by a data migration long ago --- app/models/type_de_champ.rb | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index e88043a6e..bc0725c05 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -40,25 +40,17 @@ class TypeDeChamp < ApplicationRecord store_accessor :options, :cadastres, :quartiers_prioritaires, :parcelles_agricoles, :old_pj delegate :tags_for_template, to: :dynamic_type - # TODO simplify after migrating `options` column to (non YAML encoded) JSON - class MaybeYaml - def load(options) - case options - when String - YAML.safe_load(options, [ActiveSupport::HashWithIndifferentAccess]) - when Hash - options.with_indifferent_access - else - options - end + class WithIndifferentAccess + def self.load(options) + options&.with_indifferent_access end - def dump(options) + def self.dump(options) options end end - serialize :options, MaybeYaml.new + serialize :options, WithIndifferentAccess after_initialize :set_dynamic_type after_create :populate_stable_id