Class: Cinch::Configuration::Plugins

Inherits:
Cinch::Configuration show all
Defined in:
lib/cinch/configuration/plugins.rb

Overview

Since:

  • 2.0.0

Constant Summary collapse

KnownOptions =

Since:

  • 2.0.0

[:plugins, :prefix, :suffix, :options]

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Cinch::Configuration

#[], #[]=, #initialize, #load!, #to_h

Constructor Details

This class inherits a constructor from Cinch::Configuration

Class Method Details

.default_configObject

Since:

  • 2.0.0



9
10
11
12
13
14
15
16
# File 'lib/cinch/configuration/plugins.rb', line 9

def self.default_config
  {
    :plugins => [],
    :prefix  => /^!/,
    :suffix  => nil,
    :options => Hash.new {|h,k| h[k] = {}},
  }
end

Instance Method Details

#load(new_config, from_default = false) ⇒ Object

Since:

  • 2.0.0



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cinch/configuration/plugins.rb', line 18

def load(new_config, from_default = false)
  _new_config = {}
  new_config.each do |option, value|
    case option
    when :plugins
      _new_config[option] = value.map{|v| Cinch::Utilities::Kernel.string_to_const(v)}
    when :options
      _value = self[:options]
      value.each do |k, v|
        k = Cinch::Utilities::Kernel.string_to_const(k)
        v = self[:options][k].merge(v)
        _value[k] = v
      end
      _new_config[option] = _value
    else
      _new_config[option] = value
    end
  end

  super(_new_config, from_default)
end