Class: Cloudflare::KV::Namespaces

Inherits:
Representation
  • Object
show all
Includes:
Paginate
Defined in:
lib/cloudflare/kv/namespaces.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(title, **options) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/cloudflare/kv/namespaces.rb', line 93

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

#find_by_title(title) ⇒ Object



109
110
111
# File 'lib/cloudflare/kv/namespaces.rb', line 109

def find_by_title(title)
	each.find {|namespace| namespace.title == title }
end

#representationObject



89
90
91
# File 'lib/cloudflare/kv/namespaces.rb', line 89

def representation
	Namespace
end