Skip to content

spraints/static_config

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Example

MyAppConfig = StaticConfig.build do
  first do
    env_yaml 'my_app_config'
    file Rails.root.join('config/my_app.yml'), :section => Rails.env
  end
  env 'MY_APP'
end

Now you have an object MyAppConfig that you can use anywhere.

For instance, if your config/my_app.yml looks like this:

development:
  user:
    selected:
      color: orange

You could get orange by doing this:

MyAppConfig.user.selected.color

You could override it at runtime by setting the environment variable MY_APP_USER_SELECTED_COLOR.

You can also override the entire config/my_app.yml file by storing some yaml in an environment variable called my_app_config.

To get your config to reload on each request in Rails, add this:

Rails.application.config.to_prepare do
  MyAppConfig.reload!
end

Build Status

About

Load config settings from yaml and environment variables.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages