Remove compatibility code for legacy values in database column

They were fixed by a data migration long ago
This commit is contained in:
Frederic Merizen 2019-03-11 11:16:37 +01:00
parent 45994089ca
commit 02a72507b9

View file

@ -40,25 +40,17 @@ class TypeDeChamp < ApplicationRecord
store_accessor :options, :cadastres, :quartiers_prioritaires, :parcelles_agricoles, :old_pj store_accessor :options, :cadastres, :quartiers_prioritaires, :parcelles_agricoles, :old_pj
delegate :tags_for_template, to: :dynamic_type delegate :tags_for_template, to: :dynamic_type
# TODO simplify after migrating `options` column to (non YAML encoded) JSON class WithIndifferentAccess
class MaybeYaml def self.load(options)
def load(options) options&.with_indifferent_access
case options
when String
YAML.safe_load(options, [ActiveSupport::HashWithIndifferentAccess])
when Hash
options.with_indifferent_access
else
options
end
end end
def dump(options) def self.dump(options)
options options
end end
end end
serialize :options, MaybeYaml.new serialize :options, WithIndifferentAccess
after_initialize :set_dynamic_type after_initialize :set_dynamic_type
after_create :populate_stable_id after_create :populate_stable_id