Class: Bender::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/config.rb

Overview

The Bender config engine

-- Provides a way of working with configuration
Author

Michael Heijmans ([email protected])

Copyright

Copyright © 2013-2015 Michael Heijmans

License

MIT

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

creates the instance and sets the defaults


17
18
19
20
21
# File 'lib/config.rb', line 17

def initialize
  @mutex = Mutex.new
  @config_hash = {}
  set_defaults
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, *args, &block) ⇒ Object


37
38
39
40
41
42
43
# File 'lib/config.rb', line 37

def method_missing(key, *args, &block)
  if key.match(/\=/)
    set key.to_s.gsub('=', '').to_sym, args[0]
  else
    get key.to_sym
  end
end

Class Method Details

.configure {|self.instance| ... } ⇒ Object

Takes a block for configuring Bender

Yields:

  • (self.instance)

24
25
26
27
# File 'lib/config.rb', line 24

def self.configure(&block)
  yield self.instance if block_given?
  self.instance
end

Instance Method Details

#irc_log_level=(level) ⇒ Object

Sets the Log Level using a string or symbol passed for `level`


30
31
32
33
34
35
# File 'lib/config.rb', line 30

def irc_log_level=(level)
  set(:irc_log_level, MonoLogger.const_get(level))
  if self.log
    self.log.level = self.irc_log_level
  end
end