OpenStruct
@since 2.0.0
# File lib/cinch/configuration.rb, line 23 def [](key) # FIXME also adjust method_missing raise ArgumentError, "Unknown option #{key}" unless self.class::KnownOptions.include?(key) @table[key] end
# File lib/cinch/configuration.rb, line 29 def []=(key, value) # FIXME also adjust method_missing raise ArgumentError, "Unknown option #{key}" unless self.class::KnownOptions.include?(key) modifiable[new_ostruct_member(key)] = value end
Loads a configuration from a hash by merging the hash with either the current configuration or the default configuration.
@param [Hash] new_config The configuration to load @param [Boolean] from_default If true, the configuration won't
be merged with the currently set up configuration (by prior calls to {#load} or {Bot#configure}) but with the default configuration.
@return [void]
# File lib/cinch/configuration.rb, line 44 def load(new_config, from_default = false) if from_default @table = self.class.default_config end new_config.each do |option, value| if value.is_a?(Hash) if self[option].is_a?(Configuration) self[option].load(value) else # recursive merging is handled by subclasses like # Configuration::Plugins self[option] = value end else self[option] = value end end end
Generated with the Darkfish Rdoc Generator 2.