Method: Roby::Application.overridable_configuration

Defined in:
lib/roby/app.rb

.overridable_configuration(config_set, config_key, options = {}) ⇒ Object

Defines accessors for a configuration parameter stored in #options

This method allows to define a getter and a setter for a parameter stored in #options that should be user-overridable. It builds upon #attr_config.

For instance:

overridable_configuration 'log', 'filter_backtraces'

will create a #filter_backtraces getter and a #filter_backtraces= setter which allow to respectively access the log/filter_backtraces configuration value, and override it from its value in config/app.yml

The :predicate option allows to make the setter look like a predicate:

overridable_configuration 'log', 'filter_backtraces', predicate: true

will define #filter_backtraces? instead of #filter_backtraces



226
227
228
229
230
231
232
233
234
235
# File 'lib/roby/app.rb', line 226

def self.overridable_configuration(config_set, config_key, options = {})
    options = Kernel.validate_options options, predicate: false, attr_name: config_key
    attr_config(config_set)
    define_method("#{options[:attr_name]}#{'?' if options[:predicate]}") do
        send(config_set)[config_key]
    end
    define_method("#{options[:attr_name]}=") do |new_value|
        send("#{config_set}_overrides")[config_key] = new_value
    end
end