Class: PDNS::Config
Overview
Configuration option for a DNS Server.
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of the configuration option.
Attributes inherited from API
Instance Method Summary collapse
-
#change(value = nil) ⇒ Object
Updates the object on the server.
-
#delete ⇒ Object
Disabled common methods.
-
#get ⇒ Object
Gets the current information.
-
#initialize(http, parent, name, value = nil) ⇒ Config
constructor
Creates a configuration option object.
-
#value(value = nil) ⇒ Object
Gets or sets the
valueattribute.
Methods inherited from API
Constructor Details
#initialize(http, parent, name, value = nil) ⇒ Config
Creates a configuration option object.
-
http: An HTTP object for interaction with the PowerDNS server. -
parent: This object’s parent. -
name: Name of the configuration option. -
value: Optional value of the configuration option.
39 40 41 42 43 44 45 46 47 |
# File 'lib/pdns_api/config.rb', line 39 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 |
Instance Attribute Details
#name ⇒ Object
The name of the configuration option.
26 27 28 |
# File 'lib/pdns_api/config.rb', line 26 def name @name end |
Instance Method Details
#change(value = nil) ⇒ Object
Updates the object on the server.
If value is set, the current value is used. If value is not set, value is updated and then used.
Example:
config.change('PowerDNS v3.14159265')
78 79 80 81 |
# File 'lib/pdns_api/config.rb', line 78 def change(value = nil) value(value) @http.put(@url, @info) end |
#delete ⇒ Object
Disabled common methods
30 |
# File 'lib/pdns_api/config.rb', line 30 undef_method :delete |
#get ⇒ Object
Gets the current information. This also updates value.
63 64 65 66 67 |
# File 'lib/pdns_api/config.rb', line 63 def get res = @http.get @url value(res[:value]) if res.key? :value res end |
#value(value = nil) ⇒ Object
Gets or sets the value attribute.
If value is not set the current value is returned. If value is set the object’s value is updated and info is set and returned
54 55 56 57 58 |
# File 'lib/pdns_api/config.rb', line 54 def value(value = nil) return @value if value.nil? @value = value @info = { type: 'ConfigSetting', name: @name, value: value } end |