Class: Dokuen::Config

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.



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

def initialize(path)
  @path = path
  @config = {}
  read_config
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



14
15
16
17
18
19
20
21
# File 'lib/dokuen/config.rb', line 14

def method_missing(m, *args, &block)
  str_meth = m.to_s
  if @config.has_key? str_meth
    @config[str_meth]
  else
    super
  end
end

Instance Method Details

#read_configObject



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

def read_config
  @config = YAML.load(File.read(@path))
end