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

[conditional_expose] An ability to conditaionally expose values from files #129

Open 0exp opened 3 years ago

0exp commented 3 years ago

For example:

class Config < Qonfig::DataSet
  setting :kek, expose_if: -> { some_code }
  # or
  setting :kek, expose_if: :some_method_name
  # ---
  values_file 'kek.yml' # or load_from_file (or yaml or json or etc)
end

# ---
## true for expose_if
config.kek # => '123' (some value from a kek.yml file)
## false for expose_if
config.kek # => nil (empty value)