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