Class: Textus::Action::KeyDelete

Inherits:
WriteVerb show all
Extended by:
Contract::DSL
Defined in:
lib/textus/action/key_delete.rb

Constant Summary collapse

BURN =
:sync

Instance Method Summary collapse

Methods included from Contract::DSL

arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view

Methods inherited from Base

#args, inherited

Constructor Details

#initialize(key:, if_etag: nil) ⇒ KeyDelete

Returns a new instance of KeyDelete.



20
21
22
23
24
# File 'lib/textus/action/key_delete.rb', line 20

def initialize(key:, if_etag: nil)
  super()
  @key = key
  @if_etag = if_etag
end

Instance Method Details

#call(container:, call:) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/textus/action/key_delete.rb', line 26

def call(container:, call:)
  run_with_cascade(@key, container:, call:) do
    Textus::Manifest::Data.validate_key!(@key)
    mentry = container.manifest.resolver.resolve(@key).entry

    auth(container).check_action!(action: :key_delete, actor: call.role, key: @key, extra: { if_etag: @if_etag })

    writer(container, call).delete(@key, mentry:, if_etag: @if_etag)

    container.steps.publish(
      :entry_deleted,
      ctx: Textus::Step::Context.for(container: container, call: call),
      key: @key,
    )

    { "protocol" => Textus::PROTOCOL, "ok" => true, "key" => @key, "deleted" => true }
  end
end