A simple mixin to make Ruby classes configurable
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
rakelib
spec
.codeclimate.yml Setup rubocop on CC Apr 29, 2016
.gitignore
.rspec Fix build Dec 7, 2016
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Gemfile
LICENSE
README.md
Rakefile
dry-configurable.gemspec

README.md

dry-configurable Join the Gitter chat

Gem Version Build Status Maintainability Test Coverage API Documentation Coverage

Synopsis

class App
  extend Dry::Configurable

  # Pass a block for nested configuration (works to any depth)
  setting :database do
    # Can pass a default value
    setting :dsn, 'sqlite:memory'
  end
  # Defaults to nil if no default value is given
  setting :adapter
  # Passing the reader option as true will create reader method for the class
  setting :pool, 5, reader: true
  # Passing the reader attributes works with nested configuration
  setting :uploader, reader: true do
    setting :bucket, 'dev'
  end
end

App.configure do |config|
  config.database.dsn = 'jdbc:sqlite:memory'
end

App.config.database.dsn
# => 'jdbc:sqlite:memory'
App.config.adapter # => nil
App.pool # => 5
App.uploader.bucket # => 'dev'

Links

License

See LICENSE file.