Skip to content
Helpers for accessing OTP application configuration
Elixir
Branch: master
Clone or download
Latest commit ebfd57c Sep 2, 2014
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/lib_ex initial commit Apr 30, 2014
test initial commit Apr 30, 2014
.gitignore initial commit Apr 30, 2014
LICENSE add license, readme, and hex package information May 18, 2014
README.md add license, readme, and hex package information May 18, 2014
mix.exs

README.md

LibEx.Config

LibEx.Config exposes helpers around accessing OTP application configuration

Usage

Create a new module and use LibEx.Config passing the atom for the name of the application's configuration to wrap:

defmodule MyApp.Config do
  use LibEx.Config, application: :my_app

  defkey :db_host
  defkey :db_port
  defkey :db_user
  defkey :db_pass
end

Each defkey call maps to a setting you define in your mix file:

defmodule MyApp.Mixfile do
  def application do
    [
      env: [
        env:     :dev,
        db_host: "localhost",
        db_port: 5432,
        db_user: "postgres",
        db_pass: "postgres",
        db_name: "my_app"
      ]
    ]
  end
end

Now you can get the configured variables

MyApp.Config.db_host

Or set them

MyAppConfig.db_host("other_database_name")

Authors

Jamie Winsor (jamie@vialstudios.com)

You can’t perform that action at this time.