Class: PDNS::Config
Overview
Configuration option for a DNS Server.
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of the configuration option.
-
#value(value = nil) ⇒ Object
Gets or sets the
valueattribute.
Attributes inherited from API
Instance Method Summary collapse
-
#change(value = nil) ⇒ Object
Updates the object on the server.
-
#get ⇒ Object
Gets the current information.
-
#initialize(http, parent, name, value = nil) ⇒ Config
constructor
Creates a configuration option object.
Methods inherited from API
#create, #delete, #ensure_array, #info
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 = 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 |
#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
30 31 32 |
# File 'lib/pdns_api/config.rb', line 30 def value @value 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.
74 75 76 77 |
# File 'lib/pdns_api/config.rb', line 74 def change(value = nil) value(value) @http.put(@url, @info) end |
#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 |