Class: PDNS::API
- Inherits:
-
Object
- Object
- PDNS::API
- Defined in:
- lib/pdns_api/api.rb
Overview
The superclass for all PDNS objects.
Instance Attribute Summary collapse
-
#class ⇒ Object
readonly
The class of the resource object.
-
#url ⇒ Object
readonly
The url of the resource object.
Instance Method Summary collapse
-
#create(info = nil) ⇒ Object
Creates this object on the server.
-
#delete ⇒ Object
Deletes this object.
-
#ensure_array(item) ⇒ Object
Ensures the object is an array.
-
#get ⇒ Object
Gets the information of this object from the API and use it to update the object’s information.
-
#info(info = nil) ⇒ Object
Gets and sets the object information.
Instance Attribute Details
#class ⇒ Object (readonly)
The class of the resource object.
32 33 34 |
# File 'lib/pdns_api/api.rb', line 32 def class @class end |
#url ⇒ Object (readonly)
The url of the resource object.
28 29 30 |
# File 'lib/pdns_api/api.rb', line 28 def url @url end |
Instance Method Details
#create(info = nil) ⇒ Object
Creates this object on the server
49 50 51 52 |
# File 'lib/pdns_api/api.rb', line 49 def create(info = nil) info(info) @http.post("#{@parent.url}/#{@class}", @info) end |
#delete ⇒ Object
Deletes this object
43 44 45 |
# File 'lib/pdns_api/api.rb', line 43 def delete @http.delete @url end |
#ensure_array(item) ⇒ Object
Ensures the object is an array. If it is not, an array containing the item is returned
69 70 71 72 |
# File 'lib/pdns_api/api.rb', line 69 def ensure_array(item) return item if item.is_a? Array [item] end |
#get ⇒ Object
Gets the information of this object from the API and use it to update the object’s information.
37 38 39 |
# File 'lib/pdns_api/api.rb', line 37 def get @info = @http.get @url end |
#info(info = nil) ⇒ Object
Gets and sets the object information. This does not cause an API request.
If info is set this method updates the current information.
60 61 62 63 64 |
# File 'lib/pdns_api/api.rb', line 60 def info(info = nil) return @info if info.nil? @info.merge!(info) end |