Class: WebbyNode::DNS::Record
- Defined in:
- lib/webbynode-api/dns.rb
Overview
Represents a single DNS record
Instance Attribute Summary
Attributes inherited from APIObject
Class Method Summary collapse
-
.create(options = {}) ⇒ Object
Creates a new DNS record.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Record
constructor
A new instance of Record.
Methods inherited from APIObject
#auth_get, #auth_post, auth_post, #method_missing
Constructor Details
#initialize(options = {}) ⇒ Record
Returns a new instance of Record.
160 161 162 163 164 165 |
# File 'lib/webbynode-api/dns.rb', line 160 def initialize( = {}) raise ArgumentError, ":id is a required argument" unless [:id] super() @id = [:id] @data = auth_get("/api/xml/records/#{@id}")["hash"]["record"] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class WebbyNode::APIObject
Class Method Details
.create(options = {}) ⇒ Object
Creates a new DNS record
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/webbynode-api/dns.rb', line 173 def self.create( = {}) raise ArgumentError, ":email and :token are required arguments for API access" unless [:email] && [:token] raise ArgumentError, ":data and :type are required arguments" unless [:data] && [:type] valid_types = %w(A CNAME MX) raise ArgumentError, "#{[:type]} is not a valid value for :type" unless valid_types.include?([:type]) @id = [:id] .delete(:id) for key in .keys if %w(type name data aux ttl).include? key.to_s ["record[#{key.to_s}]"] = [key] .delete(key) end end return auth_post("/api/xml/dns/#{@id}/records/new", :query => )["hash"]["record"] end |