Class: Textus::Write::Delete

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/write/delete.rb

Instance Method Summary collapse

Constructor Details

#initialize(container:, call:) ⇒ Delete

Returns a new instance of Delete.



4
5
6
7
8
9
10
# File 'lib/textus/write/delete.rb', line 4

def initialize(container:, call:)
  @container    = container
  @call         = call
  @manifest     = container.manifest
  @authorizer   = container.authorizer
  @events       = container.events
end

Instance Method Details

#call(key, if_etag: nil, suppress_events: false) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/textus/write/delete.rb', line 12

def call(key, if_etag: nil, suppress_events: false)
  Textus::Manifest::Data.validate_key!(key)
  mentry = @manifest.resolver.resolve(key).entry

  @authorizer.authorize_write!(mentry, role: @call.role)

  writer.delete(key, mentry: mentry, if_etag: if_etag)

  unless suppress_events
    @events.publish(:entry_deleted,
                    ctx: hook_context,
                    key: key)
  end

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