Module: ExpanderConfig

Included in:
CopyExpander, Expander
Defined in:
lib/expander_config.rb

Overview

Load and manage configuration settings

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



23
24
25
# File 'lib/expander_config.rb', line 23

def method_missing(method_name, *args, &block)
  @config.has_key?("#{method_name}") ? @config["#{method_name}"] : args[0]
end

Instance Method Details

#config_fileObject



15
16
17
# File 'lib/expander_config.rb', line 15

def config_file
  @config_file
end

#hashObject



19
20
21
# File 'lib/expander_config.rb', line 19

def hash
  @config
end

#load_config(argv) ⇒ Object



9
10
11
12
13
# File 'lib/expander_config.rb', line 9

def load_config argv
  @config_file = argv.length > 1 ? "#{argv[1]}.yml" : 'expander.yml'
  @config = File.exist?(@config_file) ? YAML.load_file(@config_file) : @config = {}
  @config
end