Class: PDNS::Metadata
Overview
Zone Metadata
Instance Attribute Summary
Attributes inherited from API
Instance Method Summary collapse
-
#change(value) ⇒ Object
Change metadata.
-
#get ⇒ Object
Retrieve metadata value.
-
#initialize(http, parent, kind, info = {}) ⇒ Metadata
constructor
A new instance of Metadata.
-
#value(value = nil) ⇒ Object
Set the metadata value.
Methods inherited from API
#create, #delete, #ensure_array, hash_string_to_sym, hash_sym_to_string, #info
Constructor Details
#initialize(http, parent, kind, info = {}) ⇒ Metadata
Returns a new instance of Metadata.
5 6 7 8 9 10 11 12 |
# File 'lib/pdns_api/metadata.rb', line 5 def initialize(http, parent, kind, info = {}) @class = :metadata @http = http @parent = parent @kind = kind @info = info @url = "#{parent.url}/metadata/#{kind}" end |
Instance Method Details
#change(value) ⇒ Object
Change metadata
34 35 36 37 |
# File 'lib/pdns_api/metadata.rb', line 34 def change(value) value(value) @http.put(@url, @info) end |
#get ⇒ Object
Retrieve metadata value
28 29 30 31 |
# File 'lib/pdns_api/metadata.rb', line 28 def get res = @http.get @url return value if res.key? :value end |
#value(value = nil) ⇒ Object
Set the metadata value
17 18 19 20 21 22 23 24 25 |
# File 'lib/pdns_api/metadata.rb', line 17 def value(value = nil) return @info[:metadata] if value.nil? # Convert to array if value is string value = [value] if value.is_a? String # Set info @info = { type: 'Metadata', kind: @kind, metadata: value } end |