Class: Optimacms::Appdata::Settings
- Inherits:
-
Object
- Object
- Optimacms::Appdata::Settings
- Defined in:
- lib/optimacms/appdata/settings.rb
Class Method Summary collapse
- .filename_config ⇒ Object
- .get_config_value(name, _env, v_def = nil) ⇒ Object
- .get_content_info(_env, name) ⇒ Object
- .list_content(_env) ⇒ Object
- .method_missing(m, *args, &block) ⇒ Object
- .settings ⇒ Object
- .storage_repo_local_path(storage) ⇒ Object
Class Method Details
.filename_config ⇒ Object
14 15 16 |
# File 'lib/optimacms/appdata/settings.rb', line 14 def self.filename_config File.join(Rails.root, 'config/appdata', 'appdata.yml') end |
.get_config_value(name, _env, v_def = nil) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/optimacms/appdata/settings.rb', line 59 def self.get_config_value(name, _env, v_def=nil) e = _env e = 'default' unless e v = settings[e][name.to_s] || settings['default'][name.to_s] || settings[name] || v_def v end |
.get_content_info(_env, name) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/optimacms/appdata/settings.rb', line 25 def self.get_content_info(_env, name) list = get_config_value("content", _env) res = nil list.each do |v| if v['name']==name res = v break end end res end |
.list_content(_env) ⇒ Object
19 20 21 22 23 |
# File 'lib/optimacms/appdata/settings.rb', line 19 def self.list_content(_env) list = get_config_value("content", _env) list end |
.method_missing(m, *args, &block) ⇒ Object
70 71 72 73 |
# File 'lib/optimacms/appdata/settings.rb', line 70 def self.method_missing(m, *args, &block) v = get_config_value(m.to_s, args[0]) v end |
.settings ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/optimacms/appdata/settings.rb', line 6 def self.settings return @config if @config # load from yaml @config = YAML.load_file(filename_config) @config end |
.storage_repo_local_path(storage) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/optimacms/appdata/settings.rb', line 41 def self.storage_repo_local_path(storage) #e = _env #dir_base_path = get_config_value("appdata_local_repo_dir", e) d = storage['local_repo_dir'] if d[0]=='/' d_repo = File.join(d) else d_repo = File.join(Rails.root, d) end d_repo end |