Class: MrPoole::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/mr_poole/config.rb
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/mr_poole/config.rb', line 18
def initialize
begin
if File.exists?('_config.yml')
yaml = YAML.load(File.read('_config.yml'))
@config = OpenStruct.new(yaml["poole"])
@config.srcdir = yaml['source'] if yaml['source']
check_word_separator
else
@config = OpenStruct.new
end
rescue TypeError, ::Psych::SyntaxError
bad_yaml_message
exit
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
42
43
44
|
# File 'lib/mr_poole/config.rb', line 42
def method_missing(sym, *args)
@config.send(sym)
end
|
Instance Method Details
#empty? ⇒ Boolean
34
35
36
|
# File 'lib/mr_poole/config.rb', line 34
def empty?
@config == OpenStruct.new
end
|
#inspect ⇒ Object
38
39
40
|
# File 'lib/mr_poole/config.rb', line 38
def inspect
@config.inspect
end
|