Module: Isaac::Config
- Defined in:
- lib/isaac/config.rb
Defined Under Namespace
Classes: Data
Class Method Summary collapse
- .[](arg) ⇒ Object
- .[]=(arg, val) ⇒ Object
- .config(network = nil) ⇒ Object
- .data ⇒ Object
- .data=(data) ⇒ Object (also: config=)
- .default_network ⇒ Object
- .dirty=(bool) ⇒ Object
- .dirty? ⇒ Boolean
- .loaded? ⇒ Boolean
- .method_missing(method, *args) ⇒ Object
- .networks ⇒ Object
- .write_config(filename = nil) ⇒ Object
Class Method Details
.[](arg) ⇒ Object
41 42 43 |
# File 'lib/isaac/config.rb', line 41 def [](arg) config[arg] end |
.[]=(arg, val) ⇒ Object
45 46 47 |
# File 'lib/isaac/config.rb', line 45 def []=(arg,val) config[arg] = val end |
.config(network = nil) ⇒ Object
16 17 18 19 |
# File 'lib/isaac/config.rb', line 16 def config(network=nil) network ||= default_network @data && @data.config[network] || {} end |
.data ⇒ Object
6 7 8 |
# File 'lib/isaac/config.rb', line 6 def data @data end |
.data=(data) ⇒ Object Also known as: config=
10 11 12 13 |
# File 'lib/isaac/config.rb', line 10 def data=(data) @data = data self.dirty = false end |
.default_network ⇒ Object
25 26 27 |
# File 'lib/isaac/config.rb', line 25 def default_network networks.include?('default') ? 'default' : networks.first end |
.dirty=(bool) ⇒ Object
37 38 39 |
# File 'lib/isaac/config.rb', line 37 def dirty=(bool) @dirty = bool end |
.dirty? ⇒ Boolean
33 34 35 |
# File 'lib/isaac/config.rb', line 33 def dirty? @dirty == true end |
.loaded? ⇒ Boolean
29 30 31 |
# File 'lib/isaac/config.rb', line 29 def loaded? !data.nil? end |
.method_missing(method, *args) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/isaac/config.rb', line 55 def method_missing(method, *args) if method.to_s =~ /=$/ base_name = method.to_s.gsub(/=$/,'') self.dirty = true data.config[default_network][base_name] = args.first elsif config.has_key?(method.to_s) config[method.to_s] end end |
.networks ⇒ Object
21 22 23 |
# File 'lib/isaac/config.rb', line 21 def networks @data && @data.networks || [] end |
.write_config(filename = nil) ⇒ Object
49 50 51 52 53 |
# File 'lib/isaac/config.rb', line 49 def write_config(filename=nil) File.open(filename || data.config_filename, 'w') do |file| file << data.to_yaml end end |