Class: Cloudflare::DNS::Records

Inherits:
Representation
  • Object
show all
Includes:
Paginate
Defined in:
lib/cloudflare/dns.rb

Constant Summary

Constants inherited from Representation

Representation::WRAPPER

Instance Method Summary collapse

Methods included from Paginate

#each, #empty?, #find_by_id

Methods inherited from Representation

#errors, #messages, #represent, #represent_message, #result, #results, #success?, #to_hash, #to_id

Instance Method Details

#create(type, name, content, **options) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cloudflare/dns.rb', line 64

def create(type, name, content, **options)
	payload = {type: type, name: name, content: content, **options}
	
	Record.post(@resource, payload) do |resource, response|
		value = response.read
		result = value[:result]
		 = response.headers
		
		if id = result[:id]
			resource = resource.with(path: id)
		end
		
		Record.new(resource, value: value, metadata: )
	end
end

#find_by_name(name) ⇒ Object



80
81
82
# File 'lib/cloudflare/dns.rb', line 80

def find_by_name(name)
	each(name: name).find{|record| record.name == name}
end

#representationObject



60
61
62
# File 'lib/cloudflare/dns.rb', line 60

def representation
	Record
end