Method: Ruber::SettingsContainer#add_setting

Defined in:
lib/ruber/settings_container.rb

#add_setting(opt) ⇒ nil Also known as: add_option

Adds a setting to the container

Note: this method also deletes the configuration dialog, so a new one will be created the next time it’s needed

following methods:

  • @name@: takes no arguments and returns a symbol corresponding to the name of the setting

  • @group@: takes no arguments and returns a symbol corresponding to the group the setting belongs to

  • @default@: takes one argument of class @Binding@ and returns the default value

to use for the setting

If the object also has a @relative_path@ method and that method returns true, then the setting will be treated a a path relative to the base directory already exists

Parameters:

  • the (Object)

    settings object describing the setting to add. It must have the three

Returns:

  • (nil)

Raises:

  • ArgumentError if an option with the same name nad belonging to the same group



208
209
210
211
212
213
214
215
216
217
# File 'lib/ruber/settings_container.rb', line 208

def add_setting opt
  full_name = [opt.group, opt.name]
  if @known_options[full_name]
    raise ArgumentError, "An option with name #{opt.name} belonging to group #{opt.group} already exists"
  end
  @known_options[full_name] = opt
  @options[full_name] = @backend[opt]
  delete_dialog
  nil
end