Class: PDNS::Metadata
Overview
Metadata for a zone.
Instance Attribute Summary collapse
-
#kind ⇒ name
The kind of metadata.
Attributes inherited from API
Instance Method Summary collapse
-
#change(value = nil) ⇒ Hash
Changes this object’s information on the server.
-
#get ⇒ Hash
Gets the current information.
-
#initialize(http, parent, kind, value = []) ⇒ Metadata
constructor
Creates a configuration option object.
-
#value(value = nil) ⇒ String
Gets or sets the
value
attribute.
Methods inherited from API
#create, #delete, #ensure_array, #info
Constructor Details
#initialize(http, parent, kind, value = []) ⇒ Metadata
Creates a configuration option object.
36 37 38 39 40 41 42 43 44 |
# File 'lib/pdns_api/metadata.rb', line 36 def initialize(http, parent, kind, value = []) @class = :metadata @http = http @parent = parent @kind = kind @url = "#{parent.url}/#{@class}/#{kind}" @value = get if value.empty? value(@value) end |
Instance Attribute Details
#kind ⇒ name
Returns the kind of metadata.
26 27 28 |
# File 'lib/pdns_api/metadata.rb', line 26 def kind @kind end |
Instance Method Details
#change(value = nil) ⇒ Hash
Changes this object’s information on the server.
89 90 91 92 |
# File 'lib/pdns_api/metadata.rb', line 89 def change(value = nil) value(value) @http.put(@url, @info) end |
#get ⇒ Hash
Gets the current information. This also updates value
.
70 71 72 73 74 |
# File 'lib/pdns_api/metadata.rb', line 70 def get res = @http.get @url value(res[:value]) if res.key? :value res end |
#value(value = nil) ⇒ String
Gets or sets the value
attribute.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pdns_api/metadata.rb', line 53 def value(value = nil) return @info[:metadata] if value.nil? # Convert to array if value is string value = ensure_array(value) # Set value and info @info = { type: 'Metadata', kind: @kind, metadata: value } @value = value end |