Class: PDNS::API
- Inherits:
-
Object
- Object
- PDNS::API
- Defined in:
- lib/pdns_api/api.rb
Overview
Class for interacting with the API
Instance Attribute Summary collapse
-
#class ⇒ Object
readonly
Returns the value of attribute class.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#create(info = nil) ⇒ Object
Create this object on the server.
-
#delete ⇒ Object
Delete this object.
-
#ensure_array(item) ⇒ Object
Helper methods.
-
#get ⇒ Object
Get information for this object.
-
#info(info = nil) ⇒ Object
Get/set info.
-
#initialize(args) ⇒ API
constructor
A new instance of API.
Constructor Details
Instance Attribute Details
#class ⇒ Object (readonly)
Returns the value of attribute class.
7 8 9 |
# File 'lib/pdns_api/api.rb', line 7 def class @class end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/pdns_api/api.rb', line 7 def url @url end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'lib/pdns_api/api.rb', line 7 def version @version end |
Class Method Details
.hash_string_to_sym(hash) ⇒ Object
54 55 56 |
# File 'lib/pdns_api/api.rb', line 54 def self.hash_string_to_sym(hash) hash.map { |string, value| [string.to_sym, value] }.to_h end |
.hash_sym_to_string(hash) ⇒ Object
50 51 52 |
# File 'lib/pdns_api/api.rb', line 50 def self.hash_sym_to_string(hash) hash.map { |symbol, value| [symbol.to_s, value] }.to_h end |
Instance Method Details
#create(info = nil) ⇒ Object
Create this object on the server
31 32 33 34 |
# File 'lib/pdns_api/api.rb', line 31 def create(info = nil) info(info) @http.post("#{@parent.url}/#{@class}", @info) end |
#delete ⇒ Object
Delete this object
26 27 28 |
# File 'lib/pdns_api/api.rb', line 26 def delete @http.delete @url end |
#ensure_array(item) ⇒ Object
Helper methods
45 46 47 48 |
# File 'lib/pdns_api/api.rb', line 45 def ensure_array(item) return item if item.is_a? Array [item] end |
#get ⇒ Object
Get information for this object
21 22 23 |
# File 'lib/pdns_api/api.rb', line 21 def get @info = @http.get @url end |
#info(info = nil) ⇒ Object
Get/set info
37 38 39 40 41 |
# File 'lib/pdns_api/api.rb', line 37 def info(info = nil) return @info if info.nil? @info.merge!(info) end |