Class: Configuration

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Configuration

Returns a new instance of Configuration.



6
7
8
9
# File 'lib/configuration.rb', line 6

def initialize(hash)
  update(hash)
  update('environment' => 'production') if environment.nil?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



11
12
13
14
15
16
17
# File 'lib/configuration.rb', line 11

def method_missing(name, *args, &block)
  if name.to_s[-1,1] == "="
    self[name.to_s[0...-1]] = args[0]
  else
    self[name.to_s]
  end
end

Class Method Details

.loadObject



2
3
4
# File 'lib/configuration.rb', line 2

def self.load
  Configuration.new(YAML.load_file(CONFIG_FILE) || {})
end