Class: DNSUpdater::Config
- Inherits:
-
Hash
- Object
- Hash
- DNSUpdater::Config
- Defined in:
- lib/dnsupdater/config.rb
Overview
Config file, configuration handling
Class Method Summary collapse
Instance Method Summary collapse
- #getDefaultProtocol ⇒ Object
- #getTargetProtocol(name) ⇒ Object
-
#initialize(configFile = nil) ⇒ Config
constructor
A new instance of Config.
- #setTargetProtocol(source, protocol) ⇒ Object
Constructor Details
#initialize(configFile = nil) ⇒ Config
Returns a new instance of Config.
17 18 19 20 21 22 23 |
# File 'lib/dnsupdater/config.rb', line 17 def initialize(configFile = nil) @ConfigFile = nil @ConfigFile = Pathname.new(configFile) unless configFile.to_s.empty? @TargetProtocol = {} update(load) end |
Class Method Details
.addDefault(name, config) ⇒ Object
44 45 46 |
# File 'lib/dnsupdater/config.rb', line 44 def self.addDefault(name, config) getDefaultConfig[name] = config end |
.getDefaultConfig ⇒ Object
10 11 12 13 14 15 |
# File 'lib/dnsupdater/config.rb', line 10 def self.getDefaultConfig @@DefaultConfig ||= { 'Default' => 'PowerDNS' } @@DefaultConfig end |
Instance Method Details
#getDefaultProtocol ⇒ Object
25 26 27 |
# File 'lib/dnsupdater/config.rb', line 25 def getDefaultProtocol self['Default'].downcase.to_sym end |
#getTargetProtocol(name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dnsupdater/config.rb', line 33 def getTargetProtocol(name) protocol = name.downcase.to_sym return @TargetProtocol[protocol] if @TargetProtocol.key?(protocol) return getDefaultProtocol if self[name]['Target'].to_s.empty? target = self[name]['Target'].downcase.to_sym return getDefaultProtocol if target == :default target end |
#setTargetProtocol(source, protocol) ⇒ Object
29 30 31 |
# File 'lib/dnsupdater/config.rb', line 29 def setTargetProtocol(source, protocol) @TargetProtocol[source] = protocol.downcase.to_sym unless protocol.to_s.empty? end |