Module: Sinatra::ConfigFile

Defined in:
lib/sinatra/config_file.rb

Instance Method Summary collapse

Instance Method Details

#config_file(*paths) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sinatra/config_file.rb', line 15

def config_file(*paths)
  Dir.chdir root do
    paths.each do |pattern|
      files = Dir.glob pattern
      files.each do |file|
        yaml = Parser.load_file(file) || {}
        yaml.each_pair do |key, value|
          set key, value unless methods(false).any? { |m| m.to_s == key.to_s }
        end
      end
      warn "WARNING: could not load config file #{pattern}" if files.empty?
    end
  end
end