Class: Mistilteinn::Config
- Inherits:
-
Object
- Object
- Mistilteinn::Config
show all
- Defined in:
- lib/mistilteinn/config.rb
Defined Under Namespace
Classes: WrapObj
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash, path = nil) ⇒ Config
21
22
23
24
|
# File 'lib/mistilteinn/config.rb', line 21
def initialize(hash, path = nil)
@hash = hash
@path = path
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/mistilteinn/config.rb', line 30
def method_missing(name, *args)
if args.empty? then
key = name.to_s
WrapObj.new(key, @hash[key] || {} )
else
super(name, *args)
end
end
|
Class Method Details
.load(path) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/mistilteinn/config.rb', line 13
def self.load(path)
if File.exist? path then
self.new(YAML.load_file(path), path)
else
self.new({} , path)
end
end
|
Instance Method Details
#exist? ⇒ Boolean
26
27
28
|
# File 'lib/mistilteinn/config.rb', line 26
def exist?
File.exist?(@path) if @path
end
|