Project

bonfig

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Configuration Mixin
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0
~> 0.8
~> 2.4
 Project Readme

Bonfig

Build Status Code Climate Coverage Status Dependency Status Gem Version

Simple configuration for modules.

Install

gem 'bonfig'

Usage

module MyModule
  extend Bonfig

  bonfig do
    config :index_name, default: 'test'
    config :redis do
      config :port, default: 6379
      config :host, default: 'localhost'
      config :db, default: 1
    end
  end
end


MyModule.config do |c|
  c.index_name = 'dev'

  c.redis = {port: 1234, host: '0.0.0.0' }
  # Or
  c.redis do |r|
    r.port = 1234
    r.host = '0.0.0.0'
  end
  # Or
  c.redis.port = 1234
  c.redis.host = '0.0.0.0'
end


puts MyModule.config.index_name # 'dev'
puts MyModule.config.redis.port  # 1234
puts MyModule.config.redis.host  # '0.0.0.0'
puts MyModule.config.redis.db  # 1