Class: Textus::Action::KeyDelete

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

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.



18
19
20
21
22
# File 'lib/textus/action/key_delete.rb', line 18

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

Instance Method Details

#call(container:, call:) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/textus/action/key_delete.rb', line 24

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

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

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