Module: ConfigFor::Sinatra

Defined in:
lib/config_for/sinatra.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registered(base) ⇒ Object


6
7
8
# File 'lib/config_for/sinatra.rb', line 6

def self.registered(base)
  base.set :config_path, lambda { File.join(base.settings.root, 'config') }
end

Instance Method Details

#config_for(name) ⇒ ActiveSupport::HashWithIndifferentAccess

Convenience loading of config files.

Examples:

class MyApp < Sinatra::Base
  register ConfigFor::Sinatra

  set :redis, Redis.new(config_for(:redis))
end

Parameters:

  • name (String, Symbol)

    the config file to load

Returns:

  • (ActiveSupport::HashWithIndifferentAccess)

    loaded config file for current environment

Raises:


21
22
23
# File 'lib/config_for/sinatra.rb', line 21

def config_for(name)
  ConfigFor.load_config!(settings.config_path, name, settings.environment)
end