Sha256: 81a543617189f228cbf9b27eae7dff8cc6a845a01c5449ba20e1ccb39b07bf53
Contents?: true
Size: 1.25 KB
Versions: 4
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true # This implements the Worker KV Store API # https://api.cloudflare.com/#workers-kv-namespace-properties require_relative '../paginate' require_relative '../representation' module Cloudflare module KV class Key < Representation def name value[:name] end end class Keys < Representation include Paginate def representation Key end end class Namespace < Representation def delete_value(name) value_representation(name).delete.success? end def id value[:id] end def keys self.with(Keys, path: 'keys') end def read_value(name) value_representation(name).value end def rename(new_title) put(title: new_title) value[:title] = new_title end def title value[:title] end def write_value(name, value) value_representation(name).put(value).success? end private def value_representation(name) self.with(Representation, path: "values/#{name}") end end class Namespaces < Representation include Paginate def representation Namespace end def create(title) represent_message(post(title: title)) end def find_by_title(title) each.find {|namespace| namespace.title == title } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems