Class: MosEisley::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mos-eisley/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



40
41
42
43
44
45
46
47
48
49
# File 'lib/mos-eisley/config.rb', line 40

def initialize
  @handler_paths = []
  @dump_errors = false
  @logging = false

  @meta = {}

  @verification_token = nil
  @bot_access_token = ''
end

Instance Attribute Details

#bot_access_tokenObject

Returns the value of attribute bot_access_token.



38
39
40
# File 'lib/mos-eisley/config.rb', line 38

def bot_access_token
  @bot_access_token
end

#dump_errorsObject

Returns the value of attribute dump_errors.



32
33
34
# File 'lib/mos-eisley/config.rb', line 32

def dump_errors
  @dump_errors
end

#handler_pathsObject

Returns the value of attribute handler_paths.



30
31
32
# File 'lib/mos-eisley/config.rb', line 30

def handler_paths
  @handler_paths
end

#loggingObject

Returns the value of attribute logging.



33
34
35
# File 'lib/mos-eisley/config.rb', line 33

def logging
  @logging
end

#metaObject (readonly)

Returns the value of attribute meta.



35
36
37
# File 'lib/mos-eisley/config.rb', line 35

def meta
  @meta
end

#public_folderObject

Returns the value of attribute public_folder.



31
32
33
# File 'lib/mos-eisley/config.rb', line 31

def public_folder
  @public_folder
end

#userObject

Returns the value of attribute user.



29
30
31
# File 'lib/mos-eisley/config.rb', line 29

def user
  @user
end

#verification_tokenObject

Returns the value of attribute verification_token.



37
38
39
# File 'lib/mos-eisley/config.rb', line 37

def verification_token
  @verification_token
end

Class Method Details

.load_config(path) ⇒ Object

Load Ruby config file

Parameters:

  • path (String)

    config file



11
12
13
14
15
# File 'lib/mos-eisley/config.rb', line 11

def self.load_config(path)
  MosEisley.logger.debug("Loading config file: #{path}")
  require File.expand_path(path)
  MosEisley.logger.info('Config.load_config done.')
end

.setup {|Config.shared| ... } ⇒ Object

Call this from your config file

Yields:



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

def self.setup
  yield Config.shared
  MosEisley.logger.debug('Config.setup block executed.')
end

.sharedMosEisley::Config

Returns the shared instance

Returns:



19
20
21
# File 'lib/mos-eisley/config.rb', line 19

def self.shared
  @shared_config ||= Config.new
end

Instance Method Details

#run_post_bootObject



55
56
57
58
# File 'lib/mos-eisley/config.rb', line 55

def run_post_boot
  @post_boot_block.call if @post_boot_block
  @post_boot_block = nil
end

#set_post_boot(&block) ⇒ Object



51
52
53
# File 'lib/mos-eisley/config.rb', line 51

def set_post_boot(&block)
  @post_boot_block = block
end