Skip to content
Johann edited this page Dec 8, 2018 · 4 revisions

Knowledge

Knowledge allows you to manage your project's configuration. You can use Knowledge::Configuration as your project's config or use your own setter to chose how and where you want to set config vars.

Basic Examples

Using defaults

knowledge = Knowledge::Learner.new

knowledge.use(name: :default)
knowledge.variables = { key: :value }
knowledge.gather!

Knowledge::Configuration.key # => "value"

Using a config file

key: value
knowledge = Knowledge::Learner.new

knowledge.use(name: :file)
knowledge.variables = 'path/to/file.yml'
knowledge.gather!

Knowledge::Configuration.key # => "value"

Using a config file with different envs

development:
    key: value
production:
    key: other_value
Knowledge.config.environment = :production

knowledge = Knowledge::Learner.new

knowledge.use(name: :file)
knowledge.variables = 'path/to/file.yml'
knowledge.gather!

Knowledge::Configuration.key # => "other_value"

Setting a variable manually

knowledge.setter.set(name: :foo, value: 42)

Knowledge::Configuration.foo # => 42

Clone this wiki locally