class PDNS::Config
Configuration option for a DNS Server
.
Attributes
@return [String] the name of the configuration option.
Public Class Methods
Creates a configuration option object.
@param http [HTTP] An HTTP
object for interaction with the PowerDNS server. @param parent [API] This object's parent. @param name [String] Name of the configuration option. @param value [String] Optional value of the configuration option.
# File lib/pdns_api/config.rb, line 40 def initialize(http, parent, name, value = nil) @class = :config @http = http @parent = parent @name = name @url = "#{parent.url}/#{@class}/#{name}" @value = get if value.nil? value(@value) end
Public Instance Methods
Changes this object's information on the server.
@param value [String, nil] Value to change the object to.
- If +value+ is set, the current +value+ is used. - If +value+ is not set, +value+ is updated and then used.
@return [Hash] result of the change.
@example
config = server.config('version') config.change('PowerDNS v3.14159265')
# File lib/pdns_api/config.rb, line 88 def change(value = nil) value(value) @http.put(@url, @info) end
Disabled common methods
# File lib/pdns_api/config.rb, line 30 undef_method :delete
Gets the current information. This also updates value
.
@return [Hash] the object's information from the API
.
# File lib/pdns_api/config.rb, line 69 def get res = @http.get @url value(res[:value]) if res.key? :value res end
Gets or sets the value
attribute.
@param value [String, nil] the value of the object. @return [String] the value of the object.
If +value+ is set the object's +value+ is updated.
# File lib/pdns_api/config.rb, line 57 def value(value = nil) return @value if value.nil? @info = { type: 'ConfigSetting', name: @name, value: value } @value = value end