516: def setdefaults(section, defs)
517: section = section.to_sym
518: call = []
519: defs.each { |name, hash|
520: if hash.is_a? Array
521: unless hash.length == 2
522: raise ArgumentError, "Defaults specified as an array must contain only the default value and the decription"
523: end
524: tmp = hash
525: hash = {}
526: [:default, :desc].zip(tmp).each { |p,v| hash[p] = v }
527: end
528: name = name.to_sym
529: hash[:name] = name
530: hash[:section] = section
531: raise ArgumentError, "Parameter #{name} is already defined" if @config.include?(name)
532: tryconfig = newsetting(hash)
533: if short = tryconfig.short
534: if other = @shortnames[short]
535: raise ArgumentError, "Parameter #{other.name} is already using short name '#{short}'"
536: end
537: @shortnames[short] = tryconfig
538: end
539: @config[name] = tryconfig
540:
541:
542:
543:
544: call << tryconfig if tryconfig.call_on_define
545: }
546:
547: call.each { |setting| setting.handle(self.value(setting.name)) }
548: end