Class: PDNS::Config

Inherits:
API
  • Object
show all
Defined in:
lib/pdns_api/config.rb

Overview

Server config

Instance Attribute Summary collapse

Attributes inherited from API

#class, #url, #version

Instance Method Summary collapse

Methods inherited from API

#create, #delete, #ensure_array, hash_string_to_sym, hash_sym_to_string, #info

Constructor Details

#initialize(http, parent, name, value = nil) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
12
13
14
15
# File 'lib/pdns_api/config.rb', line 7

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

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/pdns_api/config.rb', line 5

def name
  @name
end

#value(value = nil) ⇒ Object

Simple interfaces to metadata Get/set config value



19
20
21
# File 'lib/pdns_api/config.rb', line 19

def value
  @value
end

Instance Method Details

#change(value = nil) ⇒ Object

Change configuration



32
33
34
35
# File 'lib/pdns_api/config.rb', line 32

def change(value = nil)
  value(value)
  @http.put(@url, @info)
end

#getObject

Get configuration value



26
27
28
29
# File 'lib/pdns_api/config.rb', line 26

def get
  res = @http.get(@url)
  return value if res.key? :value
end