Merge pull request #3582 from betagouv/frederic/remove_yaml_hack
Remove compatibility code for legacy values in database column
This commit is contained in:
commit
c72febfa82
1 changed files with 5 additions and 13 deletions
|
@ -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
|
||||
class WithIndifferentAccess
|
||||
def self.load(options)
|
||||
options&.with_indifferent_access
|
||||
end
|
||||
|
||||
def self.dump(options)
|
||||
options
|
||||
end
|
||||
end
|
||||
|
||||
def dump(options)
|
||||
options
|
||||
end
|
||||
end
|
||||
|
||||
serialize :options, MaybeYaml.new
|
||||
serialize :options, WithIndifferentAccess
|
||||
|
||||
after_initialize :set_dynamic_type
|
||||
after_create :populate_stable_id
|
||||
|
|
Loading…
Reference in a new issue