Upgrade to support threads.
This commit is contained in:
parent
ff6423f2b7
commit
66137dcf7b
1 changed files with 9 additions and 11 deletions
|
@ -7,12 +7,10 @@ class Setting < ActiveRecord::Base
|
|||
after_update :delete_cache
|
||||
after_destroy :delete_cache
|
||||
|
||||
@@config = nil
|
||||
|
||||
def self.load
|
||||
|
||||
# check if config is already generated
|
||||
return @@config if @@config
|
||||
return Thread.current[:settings_config] if Thread.current[:settings_config]
|
||||
|
||||
# read all config settings
|
||||
config = {}
|
||||
|
@ -29,18 +27,18 @@ class Setting < ActiveRecord::Base
|
|||
}
|
||||
|
||||
# store for class requests
|
||||
@@config = config
|
||||
Thread.current[:settings_config] = config
|
||||
return config
|
||||
end
|
||||
|
||||
def self.get(name)
|
||||
self.load
|
||||
return @@config[name]
|
||||
return Thread.current[:settings_config][name]
|
||||
end
|
||||
|
||||
private
|
||||
def delete_cache
|
||||
@@config = nil
|
||||
Thread.current[:settings_config] = nil
|
||||
end
|
||||
def set_initial
|
||||
self.state_initial = self.state
|
||||
|
|
Loading…
Reference in a new issue