Class: Corrupt::Config

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

Overview

Singleton class to store Corrupt configuration.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/corrupt/config.rb', line 7

def options
  @options
end

Class Method Details

.[](key) ⇒ Object

Access the configured key‘s value.



10
11
12
13
# File 'lib/corrupt/config.rb', line 10

def self.[](key)
  raise 'Config not setup' unless @setup
  instance.options[key]
end

.setup(file) ⇒ Object

Setup Config with the YAML file.



16
17
18
19
# File 'lib/corrupt/config.rb', line 16

def self.setup(file)
  instance.options = YAML.load_file(file)[Corrupt.env]
  @setup = true
end