Class: AppCache::SystemParam
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AppCache::SystemParam
- Defined in:
- app/models/app_cache/system_param.rb
Class Method Summary collapse
- .cache_update ⇒ Object
- .get_cache ⇒ Object
- .get_param_value(key) ⇒ Object
- .get_params ⇒ Object
- .get_params_cache ⇒ Object
- .get_params_db ⇒ Object
Instance Method Summary collapse
Class Method Details
.cache_update ⇒ Object
14 15 16 17 18 |
# File 'app/models/app_cache/system_param.rb', line 14 def self.cache_update params = AppCache::SystemParam.all.to_json AppCache.storage.del "system_params" AppCache.storage.set("system_params", params) end |
.get_cache ⇒ Object
20 21 22 23 |
# File 'app/models/app_cache/system_param.rb', line 20 def self.get_cache params = JSON.load AppCache.storage.get "system_params" params end |
.get_param_value(key) ⇒ Object
50 51 52 53 54 |
# File 'app/models/app_cache/system_param.rb', line 50 def self.get_param_value(key) params = self.get_params param_val = params[key] || '' param_val end |
.get_params ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/models/app_cache/system_param.rb', line 42 def self.get_params if AppCache.storage self.get_params_cache else self.get_params_db end end |
.get_params_cache ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/models/app_cache/system_param.rb', line 25 def self.get_params_cache json = self.get_cache h = {} json.each do |sp| h.store(sp['param_code'], sp['param_value']) end return h end |
.get_params_db ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/models/app_cache/system_param.rb', line 34 def self.get_params_db h = {} AppCache::SystemParam.all.each do |sp| h.store(sp.param_code, sp.param_value) end h end |