Class: GermConfig
- Inherits:
-
Object
- Object
- GermConfig
- Defined in:
- lib/germ/config.rb
Defined Under Namespace
Classes: KeyError
Class Method Summary collapse
Instance Method Summary collapse
- #get_key(*keys) ⇒ Object
-
#initialize ⇒ GermConfig
constructor
A new instance of GermConfig.
- #loaded? ⇒ Boolean
Constructor Details
#initialize ⇒ GermConfig
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
14 15 16 |
# File 'lib/germ/config.rb', line 14 def loaded? @config != nil end |