Class: Textus::Application::Writes::Delete
- Inherits:
-
Object
- Object
- Textus::Application::Writes::Delete
- Defined in:
- lib/textus/application/writes/delete.rb
Instance Method Summary collapse
- #call(key, if_etag: nil, suppress_events: false) ⇒ Object
-
#initialize(ctx:, manifest:, envelope_io:, bus:, authorizer:, hook_context:) ⇒ Delete
constructor
A new instance of Delete.
Constructor Details
#initialize(ctx:, manifest:, envelope_io:, bus:, authorizer:, hook_context:) ⇒ Delete
Returns a new instance of Delete.
5 6 7 8 9 10 11 12 |
# File 'lib/textus/application/writes/delete.rb', line 5 def initialize(ctx:, manifest:, envelope_io:, bus:, authorizer:, hook_context:) @ctx = ctx @manifest = manifest @envelope_io = envelope_io @bus = bus @authorizer = @hook_context = hook_context end |
Instance Method Details
#call(key, if_etag: nil, suppress_events: false) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/textus/application/writes/delete.rb', line 14 def call(key, if_etag: nil, suppress_events: false) @manifest.validate_key!(key) mentry = @manifest.resolver.resolve(key).entry @authorizer.(mentry, role: @ctx.role) @envelope_io.delete(key, mentry: mentry, if_etag: if_etag) unless suppress_events @bus.publish(:entry_deleted, ctx: @hook_context, key: key) end { "protocol" => Textus::PROTOCOL, "ok" => true, "key" => key, "deleted" => true } end |