Module: Configuration
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
9 10 11 |
# File 'lib/webhookd/configuration.rb', line 9 def settings @settings end |
Instance Method Details
#load!(filename, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/webhookd/configuration.rb', line 11 def load!(filename, = {}) begin @settings = symbolize_keys(YAML::load_file(filename)) rescue Errno::ENOENT puts "[FATAL] configuration file '#{filename}' not found. Exiting."; exit 1 rescue Psych::SyntaxError puts "[FATAL] configuration file '#{filename}' contains invalid syntax. Exiting."; exit 1 end end |
#symbolize_keys(hash) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webhookd/configuration.rb', line 21 def symbolize_keys(hash) hash.inject({}){|result, (key, value)| new_key = case key when String then key.to_sym else key end new_value = case value when Hash then symbolize_keys(value) else value end result[new_key] = new_value result } end |