Class: Cloudflare::KV::Namespace

Inherits:
Representation
  • Object
show all
Includes:
Async::REST::Representation::Mutable
Defined in:
lib/cloudflare/kv/namespaces.rb

Constant Summary

Constants inherited from Representation

Representation::WRAPPER

Instance Method Summary collapse

Methods inherited from Representation

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

Instance Method Details

#delete_value(name) ⇒ Object



43
44
45
# File 'lib/cloudflare/kv/namespaces.rb', line 43

def delete_value(name)
	value_representation(name).delete.success?
end

#idObject



47
48
49
# File 'lib/cloudflare/kv/namespaces.rb', line 47

def id
	result[:id]
end

#keysObject



51
52
53
# File 'lib/cloudflare/kv/namespaces.rb', line 51

def keys
	self.with(Keys, path: "keys")
end

#read_value(name) ⇒ Object



55
56
57
# File 'lib/cloudflare/kv/namespaces.rb', line 55

def read_value(name)
	value_representation(name).value
end

#rename(new_title) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cloudflare/kv/namespaces.rb', line 59

def rename(new_title)
	self.class.put(@resource, title: new_title) do |resource, response|
		value = response.read
		
		if value[:success]
			result[:title] = new_title
		else
			raise RequestError.new(resource, value)
		end
	end
end

#titleObject



71
72
73
# File 'lib/cloudflare/kv/namespaces.rb', line 71

def title
	result[:title]
end

#write_value(name, value) ⇒ Object



75
76
77
# File 'lib/cloudflare/kv/namespaces.rb', line 75

def write_value(name, value)
	value_representation(name).put(value)
end