Class: SimpleConfig
- Inherits:
-
Object
- Object
- SimpleConfig
- Defined in:
- lib/simple_config.rb
Class Attribute Summary collapse
Class Method Summary collapse
- .data(full_file_name) ⇒ Object
- .full_file_name(file_name) ⇒ Object
- .method_missing(method_name, *args) ⇒ Object
Class Attribute Details
.default ⇒ Object
13 14 15 |
# File 'lib/simple_config.rb', line 13 def default @default ||= :config end |
.directory ⇒ Object
7 8 9 |
# File 'lib/simple_config.rb', line 7 def directory @directory ||= 'config' end |
Class Method Details
.data(full_file_name) ⇒ Object
30 31 32 |
# File 'lib/simple_config.rb', line 30 def data full_file_name SimpleStruct.create(YAML.load_file(full_file_name)) end |
.full_file_name(file_name) ⇒ Object
25 26 27 |
# File 'lib/simple_config.rb', line 25 def full_file_name file_name File.join(@directory, "#{file_name}.yml") end |
.method_missing(method_name, *args) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/simple_config.rb', line 17 def method_missing method_name, *args if (File.exists?(full_file_name = full_file_name(method_name))) data(full_file_name) else data(full_file_name(@default)).send(method_name, *args) end end |