Class: Flame::Application::Config
- Inherits:
-
Hash
- Object
- Hash
- Flame::Application::Config
- Defined in:
- lib/flame/application.rb
Overview
Class for Flame::Application.config
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(app, hash = {}) ⇒ Config
constructor
A new instance of Config.
-
#load_yaml(file, key: nil, set: true) ⇒ Object
Method for loading YAML-files from config directory.
Constructor Details
#initialize(app, hash = {}) ⇒ Config
Returns a new instance of Config.
82 83 84 85 |
# File 'lib/flame/application.rb', line 82 def initialize(app, hash = {}) @app = app replace(hash) end |
Instance Method Details
#[](key) ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/flame/application.rb', line 87 def [](key) result = super(key) if result.class <= Proc && result.parameters.empty? result = @app.class_exec(&result) end result end |
#load_yaml(file, key: nil, set: true) ⇒ Object
Method for loading YAML-files from config directory
108 109 110 111 112 113 114 115 |
# File 'lib/flame/application.rb', line 108 def load_yaml(file, key: nil, set: true) file = "#{file}.yml" if file.is_a? Symbol file_path = File.join(self[:config_dir], file) yaml = YAML.load_file(file_path) key ||= File.basename(file, '.*') self[key.to_sym] = yaml if set yaml end |