Class: Typhon::Config
- Inherits:
-
Object
- Object
- Typhon::Config
- Includes:
- Enumerable
- Defined in:
- lib/typhon/config.rb
Class Attribute Summary collapse
-
.settings ⇒ Object
readonly
Returns the value of attribute settings.
Class Method Summary collapse
- .[](key) ⇒ Object
- .[]=(key, val) ⇒ Object
- .each ⇒ Object
- .include?(key) ⇒ Boolean
- .loadconfig ⇒ Object
- .method_missing(k, *args, &block) ⇒ Object
Class Attribute Details
.settings ⇒ Object (readonly)
Returns the value of attribute settings.
8 9 10 |
# File 'lib/typhon/config.rb', line 8 def settings @settings end |
Class Method Details
.[](key) ⇒ Object
14 15 16 |
# File 'lib/typhon/config.rb', line 14 def [](key) @settings[key] end |
.[]=(key, val) ⇒ Object
10 11 12 |
# File 'lib/typhon/config.rb', line 10 def []=(key,val) @settings[key] = val end |
.each ⇒ Object
22 23 24 25 26 |
# File 'lib/typhon/config.rb', line 22 def each @settings.each_pair do |k, v| yield({k => v}) end end |
.include?(key) ⇒ Boolean
18 19 20 |
# File 'lib/typhon/config.rb', line 18 def include?(key) @settings.include?(key) end |
.loadconfig ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/typhon/config.rb', line 28 def loadconfig raise "Set configdir" unless @settings.include?(:configdir) file = File.join([@settings[:configdir], "typhon.yaml"]) raise "Cannot find file #{file}" unless File.exist?(file) @settings.merge!(YAML.load_file(file)) end |
.method_missing(k, *args, &block) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/typhon/config.rb', line 37 def method_missing(k, *args, &block) return @settings[k] if @settings.include?(k) k = k.to_s.gsub("_", ".") return @settings[k] if @settings.include?(k) super end |