0exp / qonfig

Powerful configuration Ruby-framework with a support for many commonly used config formats with a multi-functional API, developer-friendly DSL and object-oriented behavior.
MIT License
23 stars 8 forks source link

[dot-notation] Hash representation with dot-notated keys #110

Closed 0exp closed 4 years ago

0exp commented 4 years ago

Example:

class Config << Qonfig::DataSet
  setting :database do
    setting :host, 'localhost'
    setting :port, 6432
  end

  setting :api do
    setting :rest_enabled, true
    setting :rpc_enabled, false
  end
end

Config.new.to_h(dot_style: true)
# =>
{
  'database.host' => 'localhost',
  'database.port' => 6432,
  'api.rest_enabled' => true,
  'api.rpc_enabled' => false,
}