Method: PDNS::Server#config

Defined in:
lib/pdns_api/server.rb

#config(name = nil, value = nil) ⇒ Object

Returns existing configuration or creates a Config object.

If name is not set the current configuration is returned in a hash.

If name is set a Config object is returned using the provided name. If value is set as well, a complete config object is returned.



85
86
87
88
89
90
91
92
# File 'lib/pdns_api/server.rb', line 85

def config(name = nil, value = nil)
  return Config.new(@http, self, name, value) unless name.nil? || value.nil?
  return Config.new(@http, self, name) unless name.nil?

  # Get all current configuration
  config = @http.get("#{@url}/config")
  config.map { |c| [c[:name], c[:value]] }.to_h
end