mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 13:05:17 +08:00
3e13becf33
This should allow plugins to set class variables that will not stomp on other plugins.
21 lines
456 B
Ruby
21 lines
456 B
Ruby
# Support for a class variable that is multisite aware.
|
|
|
|
module MultisiteClassVar
|
|
|
|
def self.included(base)
|
|
base.extend ClassMethods
|
|
end
|
|
|
|
module ClassMethods
|
|
def multisite_class_var(name, &default)
|
|
@multisite_class_vars ||= {}
|
|
@multisite_class_vars[name] = {}
|
|
|
|
define_singleton_method(name) do
|
|
@multisite_class_vars[name][RailsMultisite::ConnectionManagement.current_db] ||= default.call
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|