Module: ConfigFor
- Defined in:
- lib/config_for.rb,
lib/config_for/rails.rb,
lib/config_for/config.rb,
lib/config_for/sinatra.rb,
lib/config_for/version.rb,
lib/config_for/capistrano.rb
Defined Under Namespace
Modules: Capistrano, Rails, Sinatra Classes: Config
Constant Summary collapse
- ReadError =
Class.new(StandardError)
- InvalidConfigError =
Class.new(StandardError)
- MissingEnvironmentError =
Class.new(StandardError)
- VERSION =
'0.3.1'
Class Method Summary collapse
-
.load_config(path, name, env) ⇒ ActiveSupport::HashWithIndifferentAccess
Loads yaml file “#{name}.yml” from path and gets given environment key.
-
.load_config!(path, name, env) ⇒ ActiveSupport::HashWithIndifferentAccess
Same as ConfigFor.load_config but raises exception when environment is not found.
Class Method Details
.load_config(path, name, env) ⇒ ActiveSupport::HashWithIndifferentAccess
Loads yaml file “#{name}.yml” from path and gets given environment key. In case the environment is not found, it returns empty hash.
27 28 29 |
# File 'lib/config_for.rb', line 27 def self.load_config(path, name, env) config(path, name).fetch(env) { ConfigFor::Config.empty } end |
.load_config!(path, name, env) ⇒ ActiveSupport::HashWithIndifferentAccess
Same as ConfigFor.load_config but raises exception when environment is not found. Note that this is the preferred way of loading configuration. Also it is used by Rails and Sinatra integrations.
39 40 41 |
# File 'lib/config_for.rb', line 39 def self.load_config!(path, name, env) config(path, name).fetch(env) end |