Class: GermConfig

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

Defined Under Namespace

Classes: KeyError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGermConfig

Returns a new instance of GermConfig.



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

def initialize
  load_file if file_exists?
end

Class Method Details

.get_conf(*keys) ⇒ Object



5
6
7
8
# File 'lib/germ/config.rb', line 5

def self.get_conf *keys
  @config ||= GermConfig.new
  @config.get_key *keys if @config.loaded?
end

Instance Method Details

#get_key(*keys) ⇒ Object



18
19
20
21
22
23
# File 'lib/germ/config.rb', line 18

def get_key *keys
  keys.inject(@config) do |obj,key|
    raise GermConfig::KeyError, "Broken key chain: #{keys}" unless obj
    obj = obj[key]
  end
end

#loaded?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/germ/config.rb', line 14

def loaded?
  @config != nil
end