mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 22:25:30 +08:00
24 lines
467 B
Ruby
24 lines
467 B
Ruby
# frozen_string_literal: true
|
|
|
|
module VariablesModel
|
|
extend ActiveSupport::Concern
|
|
|
|
@@default_variables = HashWithIndifferentAccess.new
|
|
|
|
included do
|
|
serialize :variables, JsonbHashSerializer
|
|
after_initialize :init_default_variables, if: :new_record?
|
|
end
|
|
|
|
class_methods do
|
|
def default_variables(dfs)
|
|
@@default_variables.merge!(dfs)
|
|
end
|
|
end
|
|
|
|
protected
|
|
|
|
def init_default_variables
|
|
self.variables = @@default_variables
|
|
end
|
|
end
|