mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 05:05:55 +08:00
22 lines
427 B
Ruby
22 lines
427 B
Ruby
module SettingsModel
|
|
extend ActiveSupport::Concern
|
|
|
|
@@default_settings = HashWithIndifferentAccess.new
|
|
|
|
included do
|
|
serialize :settings, JsonbHashSerializer
|
|
after_initialize :init_default_settings, if: :new_record?
|
|
end
|
|
|
|
class_methods do
|
|
def default_settings(dfs)
|
|
@@default_settings.merge!(dfs)
|
|
end
|
|
end
|
|
|
|
protected
|
|
|
|
def init_default_settings
|
|
self.settings = @@default_settings
|
|
end
|
|
end
|