| Class | Ohai::Config |
| In: |
lib/ohai/config.rb
|
| Parent: | Object |
Get the value of a configuration option
| config_option<Symbol>: | The configuration option to return |
| value: | The value of the configuration option |
| <ArgumentError>: | If the configuration option does not exist |
# File lib/ohai/config.rb, line 58
58: def [](config_option)
59: if @configuration.has_key?(config_option.to_sym)
60: @configuration[config_option.to_sym]
61: else
62: raise ArgumentError, "Cannot find configuration option #{config_option.to_s}"
63: end
64: end
Set the value of a configuration option
| config_option<Symbol>: | The configuration option to set (within the []) |
| value: | The value for the configuration option |
| value: | The new value of the configuration option |
# File lib/ohai/config.rb, line 74
74: def []=(config_option, value)
75: @configuration[config_option.to_sym] = value
76: end
Pass Ohai::Config.configure() a block, and it will yield @configuration.
| <block>: | A block that takes @configure as its argument |
# File lib/ohai/config.rb, line 44
44: def configure(&block)
45: yield @configuration
46: end
Check if Ohai::Config has a configuration option.
| key<Symbol>: | The configuration option to check for |
| <True>: | If the configuration option exists |
| <False>: | If the configuration option does not exist |
# File lib/ohai/config.rb, line 86
86: def has_key?(key)
87: @configuration.has_key?(key.to_sym)
88: end
Allows for simple lookups and setting of configuration options via method calls on Ohai::Config. If there any arguments to the method, they are used to set the value of the configuration option. Otherwise, it‘s a simple get operation.
| method_symbol<Symbol>: | The method called. Must match a configuration option. |
| *args: | Any arguments passed to the method |
| value: | The value of the configuration option. |
| <ArgumentError>: | If the method_symbol does not match a configuration option. |
# File lib/ohai/config.rb, line 103
103: def method_missing(method_symbol, *args)
104: if @configuration.has_key?(method_symbol)
105: if args.length == 1
106: @configuration[method_symbol] = args[0]
107: elsif args.length > 1
108: @configuration[method_symbol] = args
109: end
110: return @configuration[method_symbol]
111: else
112: raise ArgumentError, "Cannot find configuration option #{method_symbol.to_s}"
113: end
114: end