| VERSION | = | "2.1.0" |
| NOT_PASSED | = | Object.new |
Get the value of a config option
| config_option<Symbol>: | The config option to return |
| value: | The value of the config option |
| <UnknownConfigOptionError>: | If the config option does not exist and strict mode is on. |
Set the value of a config option
| config_option<Symbol>: | The config option to set (within the []) |
| value: | The value for the config option |
| value: | The new value of the config option |
| <UnknownConfigOptionError>: | If the config option does not exist and strict mode is on. |
metaprogramming to ensure that the slot for method_symbol gets set to value after any other logic is run
| method_symbol<Symbol>: | Name of the method (variable setter) |
| blk<Block>: | logic block to run in setting slot method_symbol to value |
| value<Object>: | Value to be set in config hash |
Allows you to create a new config context where you can define new options with default values.
This method allows you to open up the configurable more than once.
For example:
config_context :server_info do
configurable(:url).defaults_to("http://localhost")
end
symbol<Symbol>: the name of the context block<Block>: a block that will be run in the context of this new config class.
Gets or sets strict mode. When strict mode is on, only values which were specified with configurable(), default() or writes_with() may be retrieved or set. Getting or setting anything else will cause Mixlib::Config::UnknownConfigOptionError to be thrown.
If this is set to :warn, unknown values may be get or set, but a warning will be printed with Chef::Log.warn if this occurs.
| value<String>: | pass this value to set strict mode [optional] |
Current value of config_strict_mode
| <ArgumentError>: | if value is set to something other than true, false, or :warn |
Sets strict mode. When strict mode is on, only values which were specified with configurable(), default() or writes_with() may be retrieved or set. All other values
If this is set to :warn, unknown values may be get or set, but a warning will be printed with Chef::Log.warn if this occurs.
| value<String>: | pass this value to set strict mode [optional] |
| <ArgumentError>: | if value is set to something other than true, false, or :warn |
metaprogramming to set information about a config option. This may be used in one of two ways:
configurable(:attr) do
defaults_to 4
writes_value { |value| 10 }
end
configurable(:attr).defaults_to(4).writes_value { |value| 10 }
Currently supported configuration:
defaults_to(value): value returned when configurable has no explicit value defaults_to BLOCK: block is run when the configurable has no explicit value writes_value BLOCK: block that is run to filter a value when it is being set
| symbol<Symbol>: | Name of the config option |
| default_value<Object>: | Default value [optional] |
| block<Block>: | Logic block that calculates default value [optional] |
The value of the config option.
Pass Mixlib::Config.configure() a block, and it will yield itself
| block<Block>: | A block that is called with self.configuration as the arugment. |
Loads a given ruby file, and runs instance_eval against it in the context of the current object.
Raises an IOError if the file cannot be found, or is not readable.
| filename<String>: | A filename to read from |
Check if Mixlib::Config has a config option.
| key<Symbol>: | The config option to check for |
| <True>: | If the config option exists |
| <False>: | If the config option does not exist |
Merge an incoming hash with our config options
hash<Hash>: a hash in the same format as output by save.
self
Allows for simple lookups and setting of config options via method calls on Mixlib::Config. If there any arguments to the method, they are used to set the value of the config option. Otherwise, it‘s a simple get operation.
| method_symbol<Symbol>: | The method called. Must match a config option. |
| *args: | Any arguments passed to the method |
| value: | The value of the config option. |
| <UnknownConfigOptionError>: | If the config option does not exist and strict mode is on. |
Makes a copy of any non-default values.
This returns a shallow copy of the hash; while the hash itself is duplicated a la dup, modifying data inside arrays and hashes may modify the original Config object.
Hash of values the user has set.
For example, this config class:
class MyConfig < Mixlib::Config
default :will_be_set, 1
default :will_be_set_to_default, 1
default :will_not_be_set, 1
configurable(:computed_value) { |x| x*2 }
config_context :group do
default :will_not_be_set, 1
end
config_context :group_never_set
end
MyConfig.x = 2
MyConfig.will_be_set = 2
MyConfig.will_be_set_to_default = 1
MyConfig.computed_value = 2
MyConfig.group.x = 3
produces this:
MyConfig.save == {
:x => 2,
:will_be_set => 2,
:will_be_set_to_default => 1,
:computed_value => 4,
:group => {
:x => 3
}
}