Class: Textus::Application::Write::Delete::Impl
- Inherits:
-
Object
- Object
- Textus::Application::Write::Delete::Impl
- Defined in:
- lib/textus/application/write/delete.rb
Instance Method Summary collapse
- #call(key, if_etag: nil, suppress_events: false) ⇒ Object
-
#initialize(ctx:, caps:, writer:, hook_context:) ⇒ Impl
constructor
A new instance of Impl.
Constructor Details
#initialize(ctx:, caps:, writer:, hook_context:) ⇒ Impl
Returns a new instance of Impl.
14 15 16 17 18 19 20 21 |
# File 'lib/textus/application/write/delete.rb', line 14 def initialize(ctx:, caps:, writer:, hook_context:) @ctx = ctx @manifest = caps.manifest @events = caps.events @authorizer = caps. @writer = writer @hook_context = hook_context end |
Instance Method Details
#call(key, if_etag: nil, suppress_events: false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/textus/application/write/delete.rb', line 23 def call(key, if_etag: nil, suppress_events: false) Textus::Manifest::Data.validate_key!(key) mentry = @manifest.resolver.resolve(key).entry @authorizer.(mentry, role: @ctx.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 |