class Flame::Application::Config
Class for Flame::Application.config
Public Class Methods
new(app, hash = {})
click to toggle source
# File lib/flame/application/config.rb, line 7 def initialize(app, hash = {}) @app = app replace(hash) end
Public Instance Methods
[](key)
click to toggle source
Calls superclass method
# File lib/flame/application/config.rb, line 12 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)
click to toggle source
Method for loading YAML-files from config directory @param file [String, Symbol] file name (typecast to String with '.yml') @param key [Symbol, String, nil]
key for allocating YAML in config Hash (typecast to Symbol)
@param set [Boolean] allocating YAML in Config
Hash @example Load SMTP file from `config/smtp.yml' to config[]
config.load_yaml('smtp.yml')
@example Load SMTP file without extension, by Symbol
config.load_yaml(:smtp)
@example Load SMTP file with other key to config
config.load_yaml('smtp.yml', key: :mail)
@example Load SMTP file without allocating in config[]
config.load_yaml('smtp.yml', set: false)
# File lib/flame/application/config.rb, line 33 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