Class: Lita::Config Deprecated

Inherits:
Hash
  • Object
show all
Defined in:
lib/lita/config.rb

Overview

Deprecated.

Will be removed in Lita 5.0. Use ConfigurationBuilder instead.

An object that stores various user settings that affect Lita's behavior.

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Allows keys to be read and written with struct-like syntax.


74
75
76
77
78
79
80
81
# File 'lib/lita/config.rb', line 74

def method_missing(name, *args)
  name_string = name.to_s
  if name_string.chomp!("=")
    self[name_string] = args.first
  else
    self[name_string]
  end
end

Class Method Details

.default_configLita::Config

Initializes a new Config object with the default settings.

Returns:


8
9
10
11
12
13
14
15
16
17
# File 'lib/lita/config.rb', line 8

def default_config
  new.tap do |c|
    load_robot_configs(c)
    c.redis = new
    load_http_configs(c)
    c.adapter = new
    c.handlers = new
    load_handler_configs(c)
  end
end

Instance Method Details

#[](key) ⇒ Object

Get a config key.

Parameters:

  • key (Symbol, String)

    The key.

Returns:

  • The value.


62
63
64
# File 'lib/lita/config.rb', line 62

def [](key)
  super(key.to_sym)
end

#[]=(key, value) ⇒ Object

Sets a config key.

Parameters:

  • key (Symbol, String)

    The key.

  • value

    The value.

Returns:

  • The value.


55
56
57
# File 'lib/lita/config.rb', line 55

def []=(key, value)
  super(key.to_sym, value)
end

#finalizevoid

This method returns an undefined value.

Deeply freezes the object to prevent any further mutation.

Since:

  • 3.0.0


69
70
71
# File 'lib/lita/config.rb', line 69

def finalize
  IceNine.deep_freeze!(self)
end