Class: Cacheable::CacheConfiguration
- Inherits:
-
Object
- Object
- Cacheable::CacheConfiguration
- Defined in:
- lib/cache_configuration.rb
Constant Summary collapse
- @@cache_instance =
nil- @@logger_instance =
nil
Class Method Summary collapse
Class Method Details
.cache ⇒ Object
44 45 46 47 |
# File 'lib/cache_configuration.rb', line 44 def cache load_config if @@cache_instance.nil? @@cache_instance end |
.environment ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/cache_configuration.rb', line 36 def environment return Rails.env if defined? Rails return ENV['RACK_ENV'] if ENV['RACK_ENV'] 'test' rescue => error 'test' end |
.load_config ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cache_configuration.rb', line 18 def load_config base_path = File.('.') config_file = nil ['conf', 'config'].each do |sub_path| if File.exist?("#{base_path}/#{sub_path}/cache_configs.yml") config_file = "#{base_path}/#{sub_path}/cache_configs.yml" end end raise("You must have the file cache_configs.yml in either 'conf' or 'config' directory of your application") unless config_file configs = YAML.load_file(config_file) env = environment @@cache_instance = eval(configs[env]['cache']) @@logger_instance = eval(configs[env]['logger']) end |
.logger ⇒ Object
49 50 51 52 |
# File 'lib/cache_configuration.rb', line 49 def logger load_config if @@logger_instance.nil? @@logger_instance end |